MfwOfflineGeocoding
The MfwOfflineGeocoding plugin provides complete address information, including a structured full address, postal code and other information. The information is generated based on the stored data. It is also possible to obtain data about an object by coordinates.
Main use cases:
- obtaining an address by coordinates
- receiving coordinates by address
- getting a list of hints by address
Build status:
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.
- MfwOfflineGeocoding directory contains source files that define the API for working with addresses.
- 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 MfwOfflineGeocoding 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://hub.mos.ru/auroraos/libraries/mfw-offline-geocoding.git && cd MfwOfflineGeocoding &&
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 ^(libMfwOfflineGeocoding.*).*$
%define __provides_exclude_from ^/usr/share/common/ru.auroraos/qml/MfwOfflineGeocoding/.*$
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/MfwOfflineGeocoding" MfwOfflineGeocoding EXCLUDE_FROM_ALL)
include_directories("plugins/MfwOfflineGeocoding/include/MfwOfflineGeocoding")
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}
MfwOfflineGeocoding
)
target_include_directories(${PROJECT_NAME} PRIVATE
$<BUILD_INTERFACE:
${CMAKE_SOURCE_DIR}/plugins/MfwOfflineGeocoding/include/MfwOfflineGeocoding
${CMAKE_BINARY_DIR}/plugins/MfwOfflineGeocoding/include/MfwOfflineGeocoding
${AURORA_INCLUDE_DIRS}
>)
target_link_directories(
${PROJECT_NAME}
PRIVATE
${CMAKE_SOURCE_DIR}/plugins/MfwOfflineGeocoding/
${CMAKE_BINARY_DIR}/plugins/MfwOfflineGeocoding/
)
target_link_libraries(${PROJECT_NAME}
Qt5::Quick
Qt5::Positioning
${AURORA_LDFLAGS}
MfwOfflineGeocoding
)
install(TARGETS MfwOfflineGeocoding
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 MfwOfflineGeocoding qml type
You need to add the following code to main.cpp:
#include <auroraapp.h>
#include <QtQuick>
#include <MfwOfflineGeocoding/MfwOfflineGeocoding>
int main(int argc, char *argv[])
{
qmlRegisterType<MfwOfflineGeocoding>("MfwOfflineGeocoding", 1, 0, "MfwOfflineGeocoding");
//generated code
}
Use MfwOfflineGeocoding in qml components
Add MfwOfflineGeocoding to the qml component:
//other imports
import MfwOfflineGeocoding 1.0
Page {
MfwOfflineGeocoding {
offlineGlobalPostalPath: "path/to/postal/global"
offlineCountryPostalPath:"path/to/postal/country"
offlineGeocoderPath: "path/to/geocoder-nlp"
}
}
Setting up the MfwOfflineGeoCoding component
Component Base State
-
1. Code:
MfwOfflineGeocoding { offlineGlobalPostalPath: "path/to" offlineCountryPostalPath:"path/to" offlineGeocoderPath: "path/to" } -
2. Local data source
- 2.1 Path to directory postal/global
- 2.2 Path to directory postal/country
- 2.3 Path to directory geocoder-nlp
Basic use case
Receiving an address within the radius of the area around a point with coordinates: geocoder.findAddress(geocoordinate, radius).
The method returns a json object that contains a structured address, postal code and other fields.
Obtaining local data necessary for the plugin to work
Data is generated using a script.