https://github.com/pdal/capi
PDAL C API
https://github.com/pdal/capi
Last synced: about 1 year ago
JSON representation
PDAL C API
- Host: GitHub
- URL: https://github.com/pdal/capi
- Owner: PDAL
- License: other
- Created: 2019-01-14T14:35:23.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-04-06T14:03:10.000Z (over 2 years ago)
- Last Synced: 2025-04-26T23:09:33.484Z (about 1 year ago)
- Language: C
- Size: 814 KB
- Stars: 8
- Watchers: 7
- Forks: 4
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
pdal-c: PDAL C API
==================
[//]: # (@cond Hide build status from Doxygen)
[](https://github.com/PDAL/CAPI/actions)
[](https://github.com/PDAL/CAPI/actions)
[](https://github.com/PDAL/CAPI/actions)
[](https://anaconda.org/conda-forge/pdal-c)
[](https://openupm.com/packages/com.virgis.pdal/)
[//]: # (@endcond)
# Basics
*pdal-c* is a C API for the Point Data Abstraction Library ([PDAL](https://pdal.io))
and is compatible with PDAL 1.7 and later.
*pdal-c* is released under the [BSD 3-clause license](LICENSE.md).
# Documentation
[API Documentation](https://pdal.io/CAPI/doxygen/html/index.html)
# 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](https://openupm.com/packages/com.virgis.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
``` c#
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 pipe = new List();
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](https://github.com/gradientspace/geometry3Sharp) only.
Note that `BcpData` is a custom data structure that holds the Point Cloud in a form suitable to create a [Baked PointCloud](https://medium.com/realities-io/point-cloud-rendering-7bd83c6220c8) 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`