diff --git a/thirdparty/geos/HPKBUILD b/thirdparty/geos/HPKBUILD new file mode 100644 index 0000000000000000000000000000000000000000..c5733279ea8958e6d8084e0336b51aff665959b7 --- /dev/null +++ b/thirdparty/geos/HPKBUILD @@ -0,0 +1,61 @@ +# Contributor: wupingyuan +# Maintainer: wupingyuan +pkgname=geos +pkgver=3.11.2 +pkgrel=0 +pkgdesc="GEOS is a C++ library for performing operations on two-dimensional vector geometries. It is primarily a port of the JTS Topology Suite Java library. It provides many of the algorithms used by PostGIS, the Shapely package for Python, the sf package for R, and others." +url="https://github.com/libgeos/geos" +archs=("armeabi-v7a" "arm64-v8a") +license=("LGPL v2.1") +depends=() +makedepends=() +install= +source="https://github.com/libgeos/$pkgname/archive/refs/tags/$pkgver.tar.gz" + +autounpack=true +downloadpackage=true +builddir=$pkgname-$pkgver +packagename=$builddir.tar.gz + +cxxflags= + +prepare() { + mkdir -p $builddir/$ARCH-build + if [ $ARCH == "armeabi-v7a" ] + then + cxxflags="-DCMAKE_CXX_FLAGS=-D__ARM_PCS_VFP=1" + fi + if [ $ARCH == "arm64-v8a" ] + then + cxxflags= + fi +} + +build() { + cd $builddir + ${OHOS_SDK}/native/build-tools/cmake/bin/cmake "$@" cxxflags -DOHOS_ARCH=$ARCH -B$ARCH-build -S./ -L > `pwd`/$ARCH-build/build.log 2>&1 + make -j4 -C $ARCH-build >> `pwd`/$ARCH-build/build.log 2>&1 + ret=$? + cd $OLDPWD + return $ret +} + +package() { + cd $builddir + make -C $ARCH-build install >> `pwd`/$ARCH-build/build.log 2>&1 + ret=$? + cd $OLDPWD + unset cxxflags + return $ret +} + +check() { + echo "The test must be on an OpenHarmony device!" + # 在OpenHarmony开发板中执行用例 + # ctest +} + +# 清理环境 +cleanbuild(){ + rm -rf ${PWD}/$builddir #${PWD}/$packagename +} diff --git a/thirdparty/geos/README.OpenSource b/thirdparty/geos/README.OpenSource new file mode 100644 index 0000000000000000000000000000000000000000..a3bd5953a2a69c641d04b9620f9ae1ef11808ce8 --- /dev/null +++ b/thirdparty/geos/README.OpenSource @@ -0,0 +1,11 @@ +[ + { + "Name": "geos", + "License": "LGPL v2.1", + "License File": "COPYING", + "Version Number": "LGPL v2.1", + "Owner": "wupingyuan@huawei.com", + "Upstream URL": "https://github.com/libgeos/geos/archive/refs/tags/3.11.2.tar.gz", + "Description": "GEOS is a C++ library for performing operations on two-dimensional vector geometries. It is primarily a port of the JTS Topology Suite Java library. It provides many of the algorithms used by PostGIS, the Shapely package for Python, the sf package for R, and others." + } +] diff --git a/thirdparty/geos/README_zh.md b/thirdparty/geos/README_zh.md new file mode 100644 index 0000000000000000000000000000000000000000..acec5c1c60f410b8e7d80abd0953c66de1b3bd25 --- /dev/null +++ b/thirdparty/geos/README_zh.md @@ -0,0 +1,12 @@ +# geos三方库说明 +## 功能简介 +GEOS是一个C++库,用于对二维矢量几何图形执行操作。 +## 使用约束 +- IDE版本:DevEco Studio 3.1 Release +- SDK版本:ohos_sdk_public 3.2.11.9 (API Version 9 Release) +- 三方库版本:3.11.2 +- 当前适配的功能:处理二维矢量几何图形 +- [LGPL v2.1](https://github.com/libgeos/geos) + +## 集成方式 ++ [应用hap包集成](docs/hap_integrate.md) diff --git a/thirdparty/geos/SHA512SUM b/thirdparty/geos/SHA512SUM new file mode 100644 index 0000000000000000000000000000000000000000..8d75b3a1d2030eda018dca5ba93941352c22742f --- /dev/null +++ b/thirdparty/geos/SHA512SUM @@ -0,0 +1 @@ +d3a5e9816b367518f2cd73e3c254fba7e77c19faa0aa9ce07e5a1caecdd9f3b77efc87fc75e3e84031ced620aef34f47ba980b130ef6c399f8fb1c9701bf3401 geos-3.11.2.tar.gz diff --git a/thirdparty/geos/docs/hap_integrate.md b/thirdparty/geos/docs/hap_integrate.md new file mode 100644 index 0000000000000000000000000000000000000000..4440366c7583273c3b2e84c8bb9bf93f00e8fbc0 --- /dev/null +++ b/thirdparty/geos/docs/hap_integrate.md @@ -0,0 +1,75 @@ +# geos集成到应用hap +本库是在RK3568开发板上基于OpenHarmony3.2 Release版本的镜像验证的,如果是从未使用过RK3568,可以先查看[润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld)。 +## 开发环境 +- ubuntu20.04 +- [OpenHarmony3.2Release镜像](https://gitee.com/link?target=https%3A%2F%2Frepo.huaweicloud.com%2Fopenharmony%2Fos%2F3.2-Release%2Fdayu200_standard_arm32.tar.gz) +- [ohos_sdk_public 3.2.11.9 (API Version 9 Release)](https://gitee.com/link?target=https%3A%2F%2Frepo.huaweicloud.com%2Fopenharmony%2Fos%2F3.2-Release%2Fohos-sdk-windows_linux-public.tar.gz) +- [DevEco Studio 3.1 Beta2](https://gitee.com/link?target=https%3A%2F%2Fcontentcenter-vali-drcn.dbankcdn.cn%2Fpvt_2%2FDeveloperAlliance_package_901_9%2Ff3%2Fv3%2FuJyuq3syQ2ak4hE1QZmAug%2Fdevecostudio-windows-3.1.0.400.zip%3FHW-CC-KV%3DV1%26HW-CC-Date%3D20230408T013335Z%26HW-CC-Expire%3D315360000%26HW-CC-Sign%3D96262721EDC9B34E6F62E66884AB7AE2A94C2A7B8C28D6F7FC891F46EB211A70) +- [准备三方库构建环境](../../../tools/README.md#编译环境准备) +- [准备三方库测试环境](../../../tools/README.md#ci环境准备) +## 编译三方库 +- 下载本仓库 + ``` + git clone https://gitee.com/openharmony-sig/tpc_c_cplusplus.git --depth=1 + ``` +- 三方库目录结构 + ``` + tpc_c_cplusplus/thirdparty/geos #三方库geos的目录结构如下 + ├── docs #三方库相关文档的文件夹 + ├── HPKBUILD #构建脚本 + ├── SHA512SUM #三方库校验文件 + ├── README.OpenSource #说明三方库源码的下载地址,版本,license等信息 + ├── README_zh.md + ``` + +- 将geos拷贝至tools/main目录下 + ``` + cd tpc_c_cplusplus + cp thirdparty/geos tools/main -rf + ``` +- 在tools目录下编译三方库 + 编译环境的搭建参考[准备三方库构建环境](../../../tools/README.md#编译环境准备) + ``` + cd tools + ./build.sh geos + ``` +- 三方库头文件及生成的库 + 在tools目录下会生成usr目录,该目录下存在已编译完成的32位和64位三方库 + ``` + geos-arm64-v8a-install geos-armeabi-v7a-install + ``` + +- [测试三方库](#测试三方库) + +## 应用中使用三方库 + +- 在IDE的cpp目录下新增thirdparty目录,将编译生成的库拷贝到该目录下,如下图所示 + ![thirdparty_install_dir](pic/geos_install_dir.jpg) +- 在最外层(cpp目录下)CMakeLists.txt中添加如下语句 + ``` + #将三方库加入工程中 + add_library(geos SHARED IMPORTED) + set_target_properties(geos + PROPERTIES IMPORTED_LOCATION + ${CMAKE_SOURCE_DIR}/../../../libs/${OHOS_ARCH}/libgeos.so) + add_library(geos_c SHARED IMPORTED) + set_target_properties(geos_c + PROPERTIES IMPORTED_LOCATION + ${CMAKE_SOURCE_DIR}/../../../libs/${OHOS_ARCH}/libgeos_c.so) + target_link_libraries(entry PUBLIC libace_napi.z.so geos geos_c) + #将三方库的头文件加入工程中 + target_include_directories(entry PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}/thirdparty/geos-${OHOS_ARCH}-install/include) + ``` + ![geos_usage](pic/geos_usage.jpg) +## 测试三方库 +三方库的测试使用原库自带的测试用例来做测试,[准备三方库测试环境](../../../tools/README.md#ci环境准备) + +进入到构建目录执行ctest运行测试用例(arm64-v8a-build为构建64位的目录,armeabi-v7a-build为构建32位的目录) + + ![geos_test](pic/geos_test.jpg) + +## 参考资料 +- [润和RK3568开发板标准系统快速上手](https://gitee.com/openharmony-sig/knowledge_demo_temp/tree/master/docs/rk3568_helloworld) +- [OpenHarmony三方库地址](https://gitee.com/openharmony-tpc) +- [OpenHarmony知识体系](https://gitee.com/openharmony-sig/knowledge) +- [通过DevEco Studio开发一个NAPI工程](https://gitee.com/openharmony-sig/knowledge_demo_temp/blob/master/docs/napi_study/docs/hello_napi.md) diff --git a/thirdparty/geos/docs/pic/geos_install_dir.jpg b/thirdparty/geos/docs/pic/geos_install_dir.jpg new file mode 100644 index 0000000000000000000000000000000000000000..c524f6aa3404d02cdeb62433a8e489ec4fc198a1 Binary files /dev/null and b/thirdparty/geos/docs/pic/geos_install_dir.jpg differ diff --git a/thirdparty/geos/docs/pic/geos_test.jpg b/thirdparty/geos/docs/pic/geos_test.jpg new file mode 100644 index 0000000000000000000000000000000000000000..aada107e4f4f74430ef17ec45e59417f4df9c7d8 Binary files /dev/null and b/thirdparty/geos/docs/pic/geos_test.jpg differ diff --git a/thirdparty/geos/docs/pic/geos_usage.jpg b/thirdparty/geos/docs/pic/geos_usage.jpg new file mode 100644 index 0000000000000000000000000000000000000000..8a5d2c36524376b9dd22e0c0dd7b61b63776f94c Binary files /dev/null and b/thirdparty/geos/docs/pic/geos_usage.jpg differ