Geometry Types
Geometry classes provide support for spatial and geographic data using GeoJSON-compatible structures. These types are essential for location-based applications and geospatial queries.
Import:
Source: value/geometry.ts
Geometry Types
GeometryPoint
A single point in 2D space (longitude, latitude).
Constructor
Example
GeometryLine
A line defined by two or more points.
Constructor
Example
GeometryPolygon
A polygon defined by one or more lines (outer boundary and optional holes).
Constructor
Example
GeometryMultiPoint
A collection of points.
Constructor
Example
GeometryMultiLine
A collection of lines.
Constructor
Example
GeometryMultiPolygon
A collection of polygons.
Constructor
Example
GeometryCollection
A heterogeneous collection of geometry types.
Constructor
Example
Common Methods
All geometry types share these methods:
.toJSON()
Convert to GeoJSON format.
.toString()
Convert to JSON string.
.clone()
Create a deep copy.
.equals(other)
Check if two geometries are equal.
Complete Examples
Store Locations
Delivery Routes
Service Areas
Geospatial Queries
Polygon Containment
Multiple Locations (MultiPoint)
Distance Calculations
GeoJSON Export
Complex Region with Holes
GeoJSON Compatibility
All geometry types are compatible with GeoJSON format:
Best Practices
1. Use Correct Coordinate Order
2. Close Polygons Properly
3. Use Appropriate Geometry Type
4. Validate Coordinates
Use Cases
Location-based Services - Store and query business locations
Delivery Systems - Define delivery routes and service areas
Real Estate - Property boundaries and service zones
Transportation - Transit routes and coverage areas
Environmental - Conservation areas, wildlife habitats
Urban Planning - City zones, districts, infrastructure
See Also
Data Types Overview - All custom data types
Query Builders - Using Geometry in queries
SurrealQL Geometry - Database geometry types
GeoJSON Specification - GeoJSON format standard