Skip to content

PDAL/CAPI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

251deee · Apr 6, 2024
Apr 30, 2021
May 9, 2019
Jul 4, 2018
Apr 29, 2021
Apr 6, 2024
Mar 13, 2024
Feb 4, 2023
Apr 29, 2021
Jul 26, 2018
May 15, 2019
Feb 6, 2023
Oct 26, 2020
Jan 9, 2019
Apr 4, 2024
Oct 26, 2020
Jan 12, 2019
Oct 26, 2020
Jan 9, 2019
Feb 11, 2019

Repository files navigation

pdal-c: PDAL C API

Actions Status Actions Status Actions Status

Anaconda-Server Badge openupm

Basics

pdal-c is a C API for the Point Data Abstraction Library (PDAL) and is compatible with PDAL 1.7 and later.

pdal-c is released under the BSD 3-clause license.

Documentation

API Documentation

Installation

The library can be installed as a package on Windows, Mac and Linux using Conda.

conda install -c conda-forge pdal-c

The conda package includes a tool called test_pdalc. Run this to confirm that the API configuration is correct and to report on the version of PDAL that the API is connected to.

This interface is suitable for use with C# and with Unity.

There is a Unity Package Manager (UPM) package for PDAL based on this library.

Dependencies

The library is dependent on PDAL and has currently been tested up to v2.2.0.

Usage

An example of the use of the API is given in the csharp folder which contains an integration to PDAL in C#.

NOTE - these scripts are provided for information only as examples and are not supported in any way!

Example C# Program

using System;
using System.Collections.Generic;
using Pdal;
using Newtonsoft.Json;
using g3;

namespace pdal_mesh
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");
            Config pdal = new Config();
            Console.WriteLine(pdal.Version);

            List<object> pipe = new List<object>();
            pipe.Add(".../CAPI/tests/data/las/1.2-with-color.las");
            pipe.Add(new
            {
                type = "filters.splitter",
                length = 1000
            });
            pipe.Add(new
            {
                type = "filters.delaunay"
            });

            string json = JsonConvert.SerializeObject(pipe.ToArray());

            Pipeline pl = new Pipeline(json);

            long count = pl.Execute();

            Console.WriteLine($"Point Count is {count}");

            using (PointViewIterator views = pl.Views) {
                views.Reset();

                while (views.HasNext())
                {
                    PointView view = views.Next;
                    if (view != null)
                    {
                        Console.WriteLine($"Point Count is {view.Size}");
                        Console.WriteLine($"Triangle Count is {view.MeshSize}");

                        BpcData pc = view.GetBakedPointCloud();

                        DMesh3 mesh = view.getMesh();

                    }
                }
            }
        }
    }
}

This takes a LAS file, splits the file into tiles and then creates a Delaunay Triangulation (i.e. Mesh) for each one.

This code uses the sample bindings as-is and has a dependency on Geometry3Sharp only.

Note that BcpData is a custom data structure that holds the Point Cloud in a form suitable to create a Baked PointCloud suitable for rendering as a VFX graph in Unity. This is an efficient way to display point cloud data in VR and I have used it successfully with point clouds of 10 million points.

For Developers

Build on Windows

The library can be built on Windows using the following command - which assumes that you are in a conda environment that has the conda-forge pdal package loaded:

cd CAPI
make.bat

Build on Linux and Mac

The library can be built on Linux and Mac using the following command - which assumes that you are in a conda environment that has the conda-forge pdal package loaded:

cd CAPI
cmake -G "Unix Makefiles" -DCMAKE_BUILD_TYPE=Release -DCONDA_BUILD=OFF .
make
make install

Setting -DBUILD_SHARED_LIBS=OFF enables the generation of a static (.a) library.

Code Style

This project enforces the PDAL code styles, which can checked as follows :

  • On Windows - as per astylerc
  • On Linux by running ./check_all.bash