Skip to content

plarson/fluent-postgis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

83 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

FluentPostGIS

Build Status Platforms Package Managers Twitter dizm

PostGIS support for FluentPostgreSQL and Vapor

Installation

Swift Package Manager

.package(url: "https://github.com/plarson/fluent-postgis.git", .branch("master"))

Setup

Import module

import FluentPostGIS

Add to configure.swift

try services.register(FluentPostGISProvider())

Models

Add GISGeographicPoint2D to your models

final class User: PostgreSQLModel {
    var id: Int?
    var name: String
    var location: GISGeographicPoint2D?
}
Geometric Types Geographic Types
GeometricPoint2D GeographicPoint2D
GeometricLineString2D GeographicLineString2D
GeometricPolygon2D GeographicPolygon2D
GeometricMultiPoint2D GeographicMultiPoint2D
GeometricMultiLineString2D GeographicMultiLineString2D
GeometricMultiPolygon2D GeographicMultiPolygon2D
GeometricGeometryCollection2D GeographicGeometryCollection2D

Queries

Query locations using ST_DWithin

let searchLocation = GISGeographicPoint2D(longitude: -71.060316, latitude: 48.432044)
try User.query(on: conn).filterGeometryDistanceWithin(\User.location, searchLocation, 1000).all().wait()
Queries
filterGeometryContains
filterGeometryCrosses
filterGeometryDisjoint
filterGeometryDistance
filterGeometryDistanceWithin
filterGeometryEquals
filterGeometryIntersects
filterGeometryOverlaps
filterGeometryTouches
filterGeometryWithin

💝 Contributing

Please create an issue with a description of your problem or open a pull request with a fix.

✌️ License

MIT

👽 Author

Phil Larson - http://dizm.com

Releases

No releases published

Packages

No packages published

Languages