Mfw Offline Routing

Mfw Offline Routing

The MfwOfflineRouting plugin provides data for constructing a route based on coordinates, with hints for actions at path nodes, taking into account the type of transport and other settings. The information is generated based on the stored data.

MfwOfflineRouting

The MfwOfflineRouting plugin provides data for constructing a route based on coordinates, with hints for actions at path nodes, taking into account the type of transport and other settings. The information is generated based on the stored data.

Main use cases:

  • receiving a route with complete information
  • obtaining a route object with the minimum necessary information to plot it on the map
  • updating a previously received route object

Terms of Use and Participation

The source code of the project is provided under the license, which allows its use in third-party applications.

The contributor agreement documents the rights granted by contributors of the Open Mobile Platform.

Information about the contributors is specified in the AUTHORS file.

Code of conduct is a current set of rules of the Open Mobile Platform which informs you how we expect the members of the community will interact while contributing and communicating.

Project Structure

  • CMakeLists.txt file describes the project structure for the cmake build system.
  • MfwOfflineRouting directory contains source files that define the API for working with routes.
  • plugin directory contains the plugin source code.
  • test contains unit tests.

Compatibility

The project is compatible with all the current versions of the Aurora OS.

Connect the MfwOfflineRouting component

Clone a repository

You need to add the plugin to the project root as a submodule:

git init
mkdir plugins
cd plugins/
git submodule add https://gitlab.com/omprussia/libraries/mfw-offline-routing.git && cd MfwOfflineRouting &&
git submodule update --init --recursive

Setting up the .spec file

In the .spec file in the rpm directory after the lines:

%install
%make_install

you need to add the following lines:

%define __requires_exclude ^(libMfwOfflineRouting.*|libprotobuf.so*).*$
%define __provides_exclude_from ^/usr/share/common/ru.auroraos/qml/MfwOfflineRouting/.*$

Integration into CMake

cmake_minimum_required(VERSION 3.5)

find_package (Qt5 COMPONENTS Core Network Qml Positioning Gui Quick LinguistTools REQUIRED)

include(FindPkgConfig)
pkg_search_module(AURORA auroraapp REQUIRED)
pkg_search_module(AURORA auroraapp_i18n REQUIRED)
set(CMAKE_AUTOMOC ON)
set(CMAKE_INCLUDE_CURRENT_DIR ON)

set(short_name untitled3)

file(GLOB TsFiles "translations/*.ts")
qt5_add_translation(QmFiles ${TsFiles})
add_subdirectory("plugins/MfwOfflineRouting" MfwOfflineRouting EXCLUDE_FROM_ALL)
include_directories("plugins/MfwOfflineRouting/include/MfwOfflineRouting")
set(SOURCES
    src/main.cpp
)

set(CMAKE_SKIP_RPATH FALSE)
set(CMAKE_BUILD_WITH_INSTALL_RPATH TRUE)
set(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/share/${PROJECT_NAME}/lib")

add_executable(${PROJECT_NAME} ${SOURCES} ${QmFiles})
target_compile_definitions(${PROJECT_NAME} PRIVATE
    $<$<OR:$<CONFIG:Debug>,$<CONFIG:RelWithDebInfo>>:QT_QML_DEBUG>
)
add_dependencies(${PROJECT_NAME}
    MfwOfflineRouting
)
target_include_directories(${PROJECT_NAME} PRIVATE
    $<BUILD_INTERFACE:
    ${CMAKE_SOURCE_DIR}/plugins/MfwOfflineRouting/include/MfwOfflineRouting
    ${CMAKE_BINARY_DIR}/plugins/MfwOfflineRouting/include/MfwOfflineRouting
    ${AURORA_INCLUDE_DIRS}
>)
target_link_directories(
    ${PROJECT_NAME}
    PRIVATE
    ${CMAKE_SOURCE_DIR}/plugins/MfwOfflineRouting/
    ${CMAKE_BINARY_DIR}/plugins/MfwOfflineRouting/
)
target_link_libraries(${PROJECT_NAME}
    Qt5::Quick
    Qt5::Positioning
    ${AURORA_LDFLAGS}
    MfwOfflineRouting
)
install(TARGETS MfwOfflineRouting
    DESTINATION ${CMAKE_INSTALL_RPATH}
)
install(TARGETS ${PROJECT_NAME}
    RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)
install(DIRECTORY qml
    DESTINATION share/${PROJECT_NAME}
)

foreach(_file IN LISTS QmFiles)
    get_filename_component(_filename "${_file}" NAME)
    string(REPLACE "${short_name}" "${PROJECT_NAME}" _full_filename "${_filename}")
    install(FILES ${_file} DESTINATION share/${PROJECT_NAME}/translations RENAME ${_full_filename})
endforeach()

set(IconSize 86x86 108x108 128x128 172x172)
foreach(_size IN LISTS IconSize)
    install(FILES icons/${_size}/${PROJECT_NAME}.png DESTINATION share/icons/hicolor/${_size}/apps)
endforeach()

install(FILES ${PROJECT_NAME}.desktop
    DESTINATION share/applications
)

# Get the other files reachable from the project tree in Qt Creator
file(GLOB_RECURSE IconFiles "icons" "*.png")
set(RESOURCE_FILES ${IconFiles})

file(GLOB_RECURSE QmlFiles "qml/*.qml")

add_custom_target(distfiles
    SOURCES
        ${PROJECT_NAME}.desktop
        rpm/${PROJECT_NAME}.spec
        rpm/${PROJECT_NAME}.changes.in
        rpm/${PROJECT_NAME}.changes.run.in
        ${QmlFiles}
        ${TsFiles}
        ${IconFiles})

file(WRITE "${CMAKE_BINARY_DIR}/QtCreatorDeployment.txt"
    "${CMAKE_INSTALL_PREFIX}
${CMAKE_BINARY_DIR}/${PROJECT_NAME}:bin
")

Register MfwOfflineRouting qml type

You need to add the following code to main.cpp:

#include <auroraapp.h>
#include <QtQuick>
#include <MfwOfflineRouting/MfwOfflineRouting>

int main(int argc, char *argv[])
{
    qmlRegisterType<MfwOfflineRouting>("MfwOfflineRouting", 1, 0, "MfwOfflineRouting");
    //generated code
}

Use MfwOfflineRouting in qml components

Add MfwOfflineRouting to the qml component:

//other imports
import MfwOfflineRouting 1.0

Page {

    MfwOfflineRouting {
        offlinePath: "path/to/valhalla.json"
    }
}

Setting up the MfwOfflineRouting component

Component Base State

    1. Code:
    MfwOfflineRouting {
        offlinePath: "path/to"
    }
    1. Local data source
    • 2.1 Path to the configuration file valhalla.json

Basic use case

Getting a route: getRoute(<params>), where params are parameters in accordance with the documentation (include an array of points).

The method returns a route object, which includes the coordinates of the route polyline to be drawn on the map and other fields.

Obtaining local data necessary for the plugin to work

Data is generated using a script.

This document in Russian / Перевод этого документа на русский язык