FluentPostGIS

master

Swift PostGIS support for FluentPostgreSQL and Vapor
plarson/fluent-postgis

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

Description

  • Swift Tools 4.1.0
View More Packages from this Author

Dependencies

Last updated: Tue Nov 19 2024 02:48:51 GMT-1000 (Hawaii-Aleutian Standard Time)