Couchbase Lite
Objective-C API for iOS and Mac OS
CBLGeometry.h File Reference
#import "CBLBase.h"

Go to the source code of this file.

Classes

struct  CBLGeoPoint
 A 2D geometric point. More...
 
struct  CBLGeoRect
 A 2D geometric rectangle. More...
 

Typedefs

typedef NS_ASSUME_NONNULL_BEGIN struct CBLGeoPoint CBLGeoPoint
 A 2D geometric point. More...
 
typedef struct CBLGeoRect CBLGeoRect
 A 2D geometric rectangle. More...
 

Functions

BOOL CBLGeoCoordsStringToRect (NSString *__nullable coordsStr, CBLGeoRect *outRect)
 Converts a string of four comma-separated numbers ("x0,y0,x1,y1") to a rectangle. More...
 
CBLJSONDict * CBLGeoPointToJSON (CBLGeoPoint pt)
 Converts a point to GeoJSON format. More...
 
CBLJSONDict * CBLGeoRectToJSON (CBLGeoRect rect)
 Converts a rectangle to GeoJSON format (as a polygon.) For details see http://geojson.org/geojson-spec.html#polygon. More...
 
BOOL CBLGeoJSONBoundingBox (NSDictionary *__nullable geoJSON, CBLGeoRect *outBBox)
 Computes the bounding box of a GeoJSON object. More...
 
 CBLArrayOf (NSNumber *) *CBLGeoPointToCoordPair(CBLGeoPoint pt)
 Converts a point to a JSON-compatible array of two coordinates. More...
 
BOOL CBLGeoCoordPairToPoint (NSArray *__nullable coords, CBLGeoPoint *outPoint)
 Converts a JSON array of two coordinates [x,y] back into a point. More...
 
BOOL CBLGeoCoordsToRect (NSArray *__nullable coords, CBLGeoRect *outRect)
 Converts a JSON array of four coordinates [x0, y0, x1, y1] to a rectangle. More...
 
id CBLGeoPointKey (double x, double y)
 Returns a special value that, when emitted as a key, is indexed as a geometric point. More...
 
id CBLGeoRectKey (double x0, double y0, double x1, double y1)
 Returns a special value that, when emitted as a key, is indexed as a geometric rectangle. More...
 
id CBLGeoJSONKey (NSDictionary *geoJSON)
 Returns a special value that, when emitted as a key, is indexed as a GeoJSON shape. More...
 

Typedef Documentation

◆ CBLGeoPoint

A 2D geometric point.

◆ CBLGeoRect

typedef struct CBLGeoRect CBLGeoRect

A 2D geometric rectangle.

Note that unlike CGRect and NSRect, this stores max coords, not size. A rectangle with max coords equal to the min is equivalent to a point. It is illegal for the max coords to be less than the min.

Function Documentation

◆ CBLGeoCoordsStringToRect()

BOOL CBLGeoCoordsStringToRect ( NSString *__nullable  coordsStr,
CBLGeoRect outRect 
)

Converts a string of four comma-separated numbers ("x0,y0,x1,y1") to a rectangle.

◆ CBLGeoPointToJSON()

CBLJSONDict* CBLGeoPointToJSON ( CBLGeoPoint  pt)

Converts a point to GeoJSON format.

For details see http://geojson.org/geojson-spec.html#point

◆ CBLGeoRectToJSON()

CBLJSONDict* CBLGeoRectToJSON ( CBLGeoRect  rect)

Converts a rectangle to GeoJSON format (as a polygon.) For details see http://geojson.org/geojson-spec.html#polygon.

◆ CBLGeoJSONBoundingBox()

BOOL CBLGeoJSONBoundingBox ( NSDictionary *__nullable  geoJSON,
CBLGeoRect outBBox 
)

Computes the bounding box of a GeoJSON object.

Currently only implemented for points and polygons.

◆ CBLArrayOf()

CBLArrayOf ( NSNumber *  )

Converts a point to a JSON-compatible array of two coordinates.

◆ CBLGeoCoordPairToPoint()

BOOL CBLGeoCoordPairToPoint ( NSArray *__nullable  coords,
CBLGeoPoint outPoint 
)

Converts a JSON array of two coordinates [x,y] back into a point.

◆ CBLGeoCoordsToRect()

BOOL CBLGeoCoordsToRect ( NSArray *__nullable  coords,
CBLGeoRect outRect 
)

Converts a JSON array of four coordinates [x0, y0, x1, y1] to a rectangle.

◆ CBLGeoPointKey()

id CBLGeoPointKey ( double  x,
double  y 
)

Returns a special value that, when emitted as a key, is indexed as a geometric point.

Used inside a map block, like so: emit(CBLPointKey(3.0, 4.0), value);

◆ CBLGeoRectKey()

id CBLGeoRectKey ( double  x0,
double  y0,
double  x1,
double  y1 
)

Returns a special value that, when emitted as a key, is indexed as a geometric rectangle.

◆ CBLGeoJSONKey()

id CBLGeoJSONKey ( NSDictionary *  geoJSON)

Returns a special value that, when emitted as a key, is indexed as a GeoJSON shape.

Currently only its bounding box is stored. Only points and polygons are supported; other shapes return nil.