• LOPOCS 显示 PG 中的点云数据


    作者:黄宁

    说明

    本次使用操作系统为 Centos7.6 版本

    环境准备

    安装软件源和软件

    1. 安装软件源

      sudo yum install -y epel-release
      sudo yum install -y centos-release-scl-rh
      sudo yum install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-7-x86_64/pgdg-redhat-repo-latest.noarch.rpm
      
      • 1
      • 2
      • 3
    2. 安装 gcc g++

      sudo yum install -y devtoolset-10-gcc-c++ devtoolset-10-gcc
      
      • 1
    3. 安装 readline-devel

      sudo yum install -y readline-devel
      
      • 1
    4. 安装 zlib-devel

      sudo yum install -y zlib-devel
      
      • 1
    5. 安装 libxml2-devel

      sudo yum install -y libxml2-devel
      
      • 1
    6. 安装 cmake3

       yum install -y cmake3
      
      • 1
    7. 安装 gdal31-devel

      yum install -y gdal31-devel
      
      • 1
    8. 安装 geos310-devel

      yum install geos310-devel
      
      • 1
    9. 安装 geotiff

      yum install -y libgeotiff17-devel
      
      • 1
    10. 安装 libcurl-devel

      yum install -y libcurl-devel
      
      • 1
    11. 安装 openssl11-devel openssl11-libs

      yum install -y openssl11-devel  openssl11-libs
      
      • 1

      同时删除 /usr/lib64/libssl.so 文件,重新创建一个软连接指向 libssl.so.1.1.1k

    12. 安装编译可能会用到的其他软件

      sudo yum groupinstall "Development Tools" 
      
      • 1

    PostgreSQL 13.6 (以下简称 PG)安装

    我们从 [官网](PostgreSQL: File Browser)下载 PG 13.6 的源码包,下载链接.

    1. 解压文件

      tar -xf postgresql-13.6.tar.gz
      
      • 1
    2. 进入目录并配置

      cd postgresql-13.6 && ./configure --prefix=/opt/pg13 
      
      • 1
    3. 编译

      make -j
      
      • 1
    4. 安装

      make install
      
      • 1
    5. 添加 postgres 用户

      useradd postgres
      
      • 1
    6. /opt/pg13 目录所有权改为 postgres

      chown -R postgres:postgres /opt/pg13
      
      • 1
    7. 切换到 postgres 用户

      su postgres
      
      • 1
    8. 创建数据库存储目录

      mkdir -p /opt/pg13/data
      
      • 1
    9. 修改 /home/postgres/.bashrc 文件,添加如下内容

      export PATH=$PATH:/opt/pg13/bin
      export PGDATA=/opt/pg13/data
      
      • 1
      • 2

      使其生效

      source /home/postgres/.bashrc
      
      • 1
    10. 数据库初始化

      initdb
      
      • 1
    11. 启动数据库并连接

       pg_ctl start
      psql
      
      • 1
      • 2

    到此数据库已经全部安装完成

    Yukon 1.0 安装

    1. 下载安装包

      wget https://gitee.com/isupermap/yukon4pgsql/attach_files/1108783/download/Yukon-1.0-postgres13-CentOS_x64.tar.gz
      
      • 1
    2. 安装 boost

      yum install boost
      
      • 1
    3. 安装 Yukon

      #在 root 用户下 解压安装包,导出 pg_config 和 PGDATA 环境变量,这两个环境变量,我们在 /home/postgres/.bashrc 定义,直接导出即可
      sh install -i 
      
      • 1
      • 2

    pgPointCloud 安装

    1. 下载源码

      git clone https://github.com/pgpointcloud/pointcloud.git
      
      • 1
    2. 进入 pointcloud 目录,生成 configure

      cd pointcloud && ./autogen.sh
      
      • 1
    3. configure

      ./configure
      
      • 1
    4. 编译安装

      make && make install
      
      • 1
    5. 连接到数据库,安装 pointcloud 扩展

      create extension pointcloud;
      
      • 1

    PDAL 安装

    1. 下载源码

      wget https://github.com/PDAL/PDAL/releases/download/2.4.1/PDAL-2.4.1-src.tar.gz
      
      • 1
    2. 解压文件

      tar -xf PDAL-2.4.1-src.tar.gz
      
      • 1
    3. 导出环境变量

      export CMAKE_INCLUDE_PATH=/opt/pg13/include:/usr/gdal31/include:/usr/libgeotiff17/include:/usr/include/openssl11/
      export CMAKE_LIBRARY_PATH=/opt/pg13/lib:/usr/gdal31/lib:/usr/libgeotiff17/lib
      
      • 1
      • 2
    4. 使用 g++ 10 编译器

      source /opt/rh/devtoolset-10/enable
      
      • 1
    5. 进入 pdal 目录,创建编译目录

      cd PDAL-2.4.1-src && mkdir build
      
      • 1
    6. 进入 build 目录,执行 cmake3 命令

      cmake3 .. -DBUILD_PLUGIN_PGPOINTCLOUD=ON
      
      • 1
    7. 开始编译,安装

      make  && make install
      
      • 1

    LOPOCS 安装

    下载源码

    git clone https://github.com/Oslandia/lopocs.git
    
    • 1

    安装

    1. 安装 virtualenv

       pip3 install virtualenv
      
      • 1
    2. 安装 python3-devel

      yum install python-devel
      
      • 1
    3. 安装 pgmorton

      # 下载 pgmorton
      git clone https://github.com/Oslandia/pgmorton.git
      # 进入 pgmorton 目录
      # 创建 build 目录
      mkdir build
      # 进入 build 目录,然后 cmake3 编译
      cd build
      cmake3 ..
      make
      make install
      
      # 连接数据库创建扩展 
      psql 
      create extension morton;
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
      • 14
    4. 进入 lopocs 目录安装 python 依赖包

      # 激活虚拟环境
      virtualenv -p /usr/bin/python3 venv
      source venv/bin/activate
      # 安装 numpy
      pip3 install 'numpy==1.14.3'
      # 安装其他 
      pip install -e .
      pip3 install --upgrade Werkzeug==0.16.0
      
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
    5. 复制 conf/lopocs.sample.yml 文件为 conf/lopocs.yml 修改其中的参数,其中数据库的名字为 lopocs 后边我们会创建这个数据库

      flask:
          DEBUG: False
          PG_HOST: 127.0.0.1
          PG_NAME: lopocs
          PG_PORT: 5432
          PG_USER: supermap
          PG_PASSWORD: supermap
          CACHE_DIR: /home/postgres/cache
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
    6. 创建数据库及其扩展

      createdb lopocs
      psql -d lopocs -c 'create extension postgis'
      psql -d lopocs -c 'create extension pointcloud'
      psql -d lopocs -c 'create extension pointcloud_postgis'
      psql -d lopocs -c 'create extension morton'
      
      • 1
      • 2
      • 3
      • 4
      • 5
    7. 检查是否安装成功

      # lopocs check 查看输出
      lopocs check
      
      # 输出如下
      Pdal ... 2.4.1
      Pdal plugin pgpointcloud ... ok
      PostgreSQL ... 13.6
      PostGIS extension ... 3.1.2dev
      PgPointcloud extension ... 1.2.2
      PgPointcloud-PostGIS extension ... 1.2.2
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10

    显示

    1. 修改 lopocs 代码,显示 demo 案例

      # 将 cli.py 中的 266-278 替换如下
      
       offset_x = summary['bounds']['minx'] + (summary['bounds']['maxx'] - summary['bounds']['minx']) / 2
       offset_y = summary['bounds']['miny'] + (summary['bounds']['maxy'] - summary['bounds']['miny']) / 2
       offset_z = summary['bounds']['minz'] + (summary['bounds']['maxz'] - summary['bounds']['minz']) / 2
      
      # 将 cli.py 中的 289-290 替换如下
       xmin, ymin, zmin = transform(pini, pout, summary['bounds']['minx'], summary['bounds']['miny'], summary['bounds']['minz'])
       xmax, ymax, zmax = transform(pini, pout, summary['bounds']['maxx'], summary['bounds']['maxy'], summary['bounds']['maxz'])
       
      # 将 database.py 中 193 行修改如下
      
      cls.pool = ThreadedConnectionPool(1, 50, query_con)
      
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
      • 14
    2. 导入 demo 数据

      # 在 lopocs 创建 demos 目录
      mkdir demos
      # 导入 demo 数据,导入时间较长,需要等待一会
      lopocs demo --server-url "http:192.168.90.127:5000" --work-dir demos/ --sample lyon --cesium
      
      #启动服务
      lopocs serve
      
      # 导入完成后,可以在 demos 目录下有一个 cesium-lyon.html 文件,在浏览器中打开就可以看到点云数据
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9

    数据库中的点云数据:
    点云数据

    浏览器请求 3D Tiles 数据数据流

    浏览器截图如下:
    浏览器显示

  • 相关阅读:
    MySQL高阶语句和视图
    《canvas》之第16章 碰撞检测
    pulsar简介
    企业运维实践-Nginx使用geoip2模块并利用MaxMind的GeoIP2数据库实现处理不同国家或城市的访问最佳实践指南...
    java web开发(反射)
    (2)点云库处理学习——剔除点云值
    【高级篇 / ZTNA】(7.0) ❀ 01. FortiClient EMS 下载与安装 ❀ FortiGate 防火墙
    git 缓冲区查看与设置
    快读《ASP.NET Core技术内幕与项目实战》WebApi3.1:WebApi最佳实践
    【python数据分析基础】—对列操作:获取DataFrame不同的类型columns
  • 原文地址:https://blog.csdn.net/supermapsupport/article/details/126303668