GeometryBuilder

Objective-C


@interface GeometryBuilder : NSObject

Swift

class GeometryBuilder : NSObject

Builder for constructing vector geometries (lines, multilines, polygons, multipolygons). Uses C++-backed storage for efficient point handling without ObjC overhead.

  • Initializes an empty geometry builder.

    Declaration

    Objective-C

    - (nonnull instancetype)init;

    Swift

    init()
  • Begins a new polygon definition. Call this before adding rings. All subsequent addLine: calls will be interpreted as linear rings of this polygon (first ring = outer boundary, subsequent = holes). To create a multipolygon, call beginPolygon multiple times.

    Declaration

    Objective-C

    - (void)beginPolygon;

    Swift

    func beginPolygon()
  • Adds a line string (open or closed) to the current geometry.

    Declaration

    Objective-C

    - (void)addLine:(nonnull const GLMapPoint *)points count:(NSUInteger)count;

    Swift

    func addLine(_ points: UnsafePointer<GLMapPoint>, count: UInt)

    Parameters

    points

    Pointer to an array of GLMapPoint.

    count

    Number of points in the array. @discussion If no polygon is active (i.e., beginPolygon was not called), this adds an independent line segment. Multiple such calls produce a multiline. If a polygon is active, the line becomes a ring of that polygon.

  • Adds a line string using a callback block for point generation.

    Declaration

    Objective-C

    - (void)addLine:(NSUInteger)count callback:(nonnull GetPointBlock)callback;

    Swift

    func addLine(_ count: UInt, callback: @escaping GetPointBlock)

    Parameters

    count

    Number of points to generate.

    callback

    Block that returns a point for each index from 0 to count-1. @discussion Useful for computed geometries (circles, spirals, etc.). Behaves the same as addLine:count: regarding polygon/line context.

  • Finalizes and returns vector object with immutable geometry containing all added geometries.

    • If beginPolygon was never called → linestring (or multiline if multiple addLine calls).
    • If beginPolygon was called at least once → polygon (or multipolygon if called multiple times). After build, the builder is reset to its initial empty state.

    Declaration

    Objective-C

    - (GLMapVectorObject *_Nullable)build;

    Swift

    func build() -> GLMapVectorObject?

    Return Value

    A new GLMapVectorObject, or nil if no geometry was added. @discussion The type is inferred automatically:

  • Clears all added geometries and resets the builder to its initial empty state.

    Declaration

    Objective-C

    - (void)clear;

    Swift

    func clear()