Using an IFeatureGeometryProvider, you can specify which geometry to use for editing a feature, and how to apply changes to that feature. This class has a default implementation, DefaultFeatureGeometryProvider that you can use for simple cases. Have a look at the class documentation for more information. A geometry provider can be configured on the layer.

This sample shows how you can implement an IFeatureGeometryProvider that provides a circle edit geometry for a Feature with location and radius properties.

Program: Provide circle edit geometry
class CircleGeometryProvider final : public IFeatureGeometryProvider {
public:
explicit CircleGeometryProvider(const DataType& featureType)
: _pointPropertyPath(DataPropertyPath::newBuilder().originType(featureType).property("point").build()),
_radiusPropertyPath(DataPropertyPath::newBuilder().originType(featureType).property("radius").build()) {
}
std::shared_ptr<Geometry> getGeometry(const Feature& feature) override {
auto pointGeometry = feature.getValue<std::shared_ptr<Geometry>>(_pointPropertyPath);
auto point = std::dynamic_pointer_cast<Point>(*pointGeometry);
auto radius = feature.getValue<double>(_radiusPropertyPath);
return GeometryFactory::createCircleByCenterPoint(point->getReference(), point->getLocation(), *radius);
}
std::optional<Feature> applyGeometry(Feature originalFeature, std::shared_ptr<Geometry> newGeometry) override {
auto circle = std::dynamic_pointer_cast<CircleByCenterPoint>(newGeometry);
auto point = GeometryFactory::createPoint(circle->getReference(), circle->getCenter());
auto builder = originalFeature.asBuilder();
builder.value(_pointPropertyPath, std::dynamic_pointer_cast<Geometry>(point));
builder.value(_radiusPropertyPath, circle->getRadius());
return builder.build();
}
private:
DataPropertyPath _pointPropertyPath;
DataPropertyPath _radiusPropertyPath;
};