Skip to content

Commit 7bdec5a

Browse files
author
peng.li24
committed
feat: add pycpp pybind11 wrapper layer for geometry types
Add pycpp/ directory providing thin pybind11 wrappers for shapelycpp native C++ geometry types, following the numpypy/pycpp pattern. pycpp/geometry_py.h: - Factory functions: point(f64/f32), linestring(f64/f32), polygon(f64/f32), linearring — accept Python list of coords - Cross-type distance: distance_pt_ls, distance_pt_poly, distance_ls_poly, distance_poly_ls - Cross-type intersects: intersects_ls_poly, intersects_poly_poly - All 9 predicate pair combinations (pt↔pt, pt↔ls, pt↔poly, ls↔pt, etc.) - Centroid, project, interpolate, intersection_area, polygon_exterior - BIND_PREDS / BIND_ACCESSORS macros for consistent class binding pycpp/ops_py.h: - nearest_points_poly_ls, nearest_points_ls_pt tests/module.cpp: - Refactored from 400→223 lines: uses pycpp wrappers instead of hand-written free functions and macros - Serves as reference example for consuming projects README: updated project structure to document pycpp/ directory
1 parent 994b618 commit 7bdec5a

4 files changed

Lines changed: 513 additions & 322 deletions

File tree

README.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,11 +135,14 @@ shapelycpp/
135135
│ │ └── polygon.h
136136
│ └── ops/
137137
│ └── nearest_points.h
138+
├── pycpp/ # pybind11 wrappers (thin layer: Python types → native C++)
139+
│ ├── geometry_py.h # factories, cross-type predicates, distance, accessors
140+
│ └── ops_py.h # nearest_points
138141
├── example/ # native C++ usage examples
139142
│ ├── CMakeLists.txt
140143
│ └── main.cpp
141144
├── tests/ # Python precision alignment tests
142-
│ ├── module.cpp # pybind11 test module
145+
│ ├── module.cpp # pybind11 test module (uses pycpp wrappers)
143146
│ ├── conftest.py # pytest fixtures (float64/float32 make, CppFactory)
144147
│ ├── utils.py # coordinate generators & comparison helpers
145148
│ └── test_api.py # unified precision alignment tests (float64/float32)

0 commit comments

Comments
 (0)