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, callbeginPolygonmultiple 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
pointsPointer to an array of GLMapPoint.
countNumber of points in the array. @discussion If no polygon is active (i.e.,
beginPolygonwas 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
countNumber of points to generate.
callbackBlock that returns a point for each index from 0 to
count-1. @discussion Useful for computed geometries (circles, spirals, etc.). Behaves the same asaddLine:count:regarding polygon/line context. -
Finalizes and returns vector object with immutable geometry containing all added geometries.
- If
beginPolygonwas never called → linestring (or multiline if multipleaddLinecalls). - If
beginPolygonwas called at least once → polygon (or multipolygon if called multiple times). Afterbuild, 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:
- If
-
Clears all added geometries and resets the builder to its initial empty state.
Declaration
Objective-C
- (void)clear;Swift
func clear()
Install in Dash