[pgpointcloud] Question using pgpointcloud and pqxx

David Serret Mayer david.serret at eigendynamics.com
Tue Sep 11 01:42:18 PDT 2018


Hi,

Quick question,  ¿is this the fastest way to insert a pointcloud to a patch
using pqxx for C++? It is quite fast but it *kinda feels* wrong.

std::string command = "INSERT INTO patches1 (pa) SELECT PC_MakePatch(1,
ARRAY[";
    for (auto &ele : data_vec){ //data_vect is a vector of points
        command +=
¡std::to_string(ele.x)+","+std::to_string(ele.y)+","+std::to_string(ele.z)+","+std::to_string(ele.i)+",";
    }
    command.pop_back();
    command += "])";

This is 20 times slower, but I feel it should be faster...
     pqxx::connection conn;
    conn.prepare( "insert_pt", "INSERT INTO points(pt) SELECT
PC_MakePoint(1, ARRAY[$1::float, $2::float, $3::float, $4::float])" );
  for(auto &e: data_vec){
    pqxx::result r = txn.prepared( "insert_pt" )(e.x)(e.y)(e.z)(e.i).exec();
  }


Thanks a lot!




-- 
*David Serret *- R&D Engineer at Eigen Dynamics SL
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/pgpointcloud/attachments/20180911/cffc9f0d/attachment.html>


More information about the pgpointcloud mailing list