PostGIS support for FluentPostgreSQL and Vapor
.package(url: "https://github.com/plarson/fluent-postgis.git", .branch("master"))
Import module
import FluentPostGIS
Add to configure.swift
try services.register(FluentPostGISProvider())
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 |
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 |
Please create an issue with a description of your problem or open a pull request with a fix.
MIT
Phil Larson - http://dizm.com