Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
trasch committed Feb 15, 2024
0 parents commit 878e988
Show file tree
Hide file tree
Showing 25 changed files with 1,709 additions and 0 deletions.
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
.DS_Store
/.build
/Packages
/*.xcodeproj
xcuserdata/
DerivedData/
.swiftpm/xcode/package.xcworkspace/contents.xcworkspacedata
4 changes: 4 additions & 0 deletions .spi.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
version: 1
builder:
configs:
- documentation_targets: [MVTPostgis]
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Outdooractive AG

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
212 changes: 212 additions & 0 deletions Package.resolved
Original file line number Diff line number Diff line change
@@ -0,0 +1,212 @@
{
"pins" : [
{
"identity" : "async-kit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/async-kit.git",
"state" : {
"revision" : "7ece208cd401687641c88367a00e3ea2b04311f1",
"version" : "1.19.0"
}
},
{
"identity" : "gis-tools",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Outdooractive/gis-tools",
"state" : {
"revision" : "271ffa105096a3c5889b211227c9a31dc59030db",
"version" : "1.2.0"
}
},
{
"identity" : "gzipswift",
"kind" : "remoteSourceControl",
"location" : "https://github.com/1024jp/GzipSwift.git",
"state" : {
"revision" : "7a7f17761c76a932662ab77028a4329f67d645a4",
"version" : "5.2.0"
}
},
{
"identity" : "mvt-tools",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Outdooractive/mvt-tools",
"state" : {
"revision" : "f19faad0ddbd8378ad8538909fb150b5fa6f7141",
"version" : "1.3.2"
}
},
{
"identity" : "postgres-kit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/postgres-kit",
"state" : {
"revision" : "475bf6f04ee1840917a70c32b48e4a724df4ccaf",
"version" : "2.12.3"
}
},
{
"identity" : "postgres-nio",
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/postgres-nio.git",
"state" : {
"revision" : "69ccfdf4c80144d845e3b439961b7ec6cd7ae33f",
"version" : "1.20.2"
}
},
{
"identity" : "postgresconnectionpool",
"kind" : "remoteSourceControl",
"location" : "https://github.com/Outdooractive/PostgresConnectionPool.git",
"state" : {
"revision" : "e8c65e5b0a987b678be2294a8113c5a21889c86f",
"version" : "0.7.0"
}
},
{
"identity" : "sql-kit",
"kind" : "remoteSourceControl",
"location" : "https://github.com/vapor/sql-kit.git",
"state" : {
"revision" : "b2f128cb62a3abfbb1e3b2893ff3ee69e70f4f0f",
"version" : "3.28.0"
}
},
{
"identity" : "swift-algorithms",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-algorithms.git",
"state" : {
"revision" : "f6919dfc309e7f1b56224378b11e28bab5bccc42",
"version" : "1.2.0"
}
},
{
"identity" : "swift-argument-parser",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser",
"state" : {
"revision" : "c8ed701b513cf5177118a175d85fbbbcd707ab41",
"version" : "1.3.0"
}
},
{
"identity" : "swift-atomics",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-atomics.git",
"state" : {
"revision" : "cd142fd2f64be2100422d658e7411e39489da985",
"version" : "1.2.0"
}
},
{
"identity" : "swift-collections",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-collections",
"state" : {
"revision" : "94cf62b3ba8d4bed62680a282d4c25f9c63c2efb",
"version" : "1.1.0"
}
},
{
"identity" : "swift-crypto",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-crypto.git",
"state" : {
"revision" : "cc76b894169a3c86b71bac10c78a4db6beb7a9ad",
"version" : "3.2.0"
}
},
{
"identity" : "swift-log",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-log.git",
"state" : {
"revision" : "e97a6fcb1ab07462881ac165fdbb37f067e205d5",
"version" : "1.5.4"
}
},
{
"identity" : "swift-metrics",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-metrics.git",
"state" : {
"revision" : "971ba26378ab69c43737ee7ba967a896cb74c0d1",
"version" : "2.4.1"
}
},
{
"identity" : "swift-nio",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio.git",
"state" : {
"revision" : "635b2589494c97e48c62514bc8b37ced762e0a62",
"version" : "2.63.0"
}
},
{
"identity" : "swift-nio-ssl",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-ssl.git",
"state" : {
"revision" : "7c381eb6083542b124a6c18fae742f55001dc2b5",
"version" : "2.26.0"
}
},
{
"identity" : "swift-nio-transport-services",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-nio-transport-services.git",
"state" : {
"revision" : "6cbe0ed2b394f21ab0d46b9f0c50c6be964968ce",
"version" : "1.20.1"
}
},
{
"identity" : "swift-numerics",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-numerics",
"state" : {
"revision" : "0a5bc04095a675662cf24757cc0640aa2204253b",
"version" : "1.0.2"
}
},
{
"identity" : "swift-protobuf",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-protobuf",
"state" : {
"revision" : "65e8f29b2d63c4e38e736b25c27b83e012159be8",
"version" : "1.25.2"
}
},
{
"identity" : "swift-system",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-system.git",
"state" : {
"revision" : "025bcb1165deab2e20d4eaba79967ce73013f496",
"version" : "1.2.1"
}
},
{
"identity" : "swiftyxmlparser",
"kind" : "remoteSourceControl",
"location" : "https://github.com/yahoojapan/SwiftyXMLParser",
"state" : {
"revision" : "d7a1d23f04c86c1cd2e8f19247dd15d74e0ea8be",
"version" : "5.6.0"
}
},
{
"identity" : "yams",
"kind" : "remoteSourceControl",
"location" : "https://github.com/jpsim/Yams",
"state" : {
"revision" : "9ff1cc9327586db4e0c8f46f064b6a82ec1566fa",
"version" : "4.0.6"
}
}
],
"version" : 2
}
37 changes: 37 additions & 0 deletions Package.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// swift-tools-version:5.9

import PackageDescription

let package = Package(
name: "mvt-postgis",
platforms: [
.macOS(.v13),
.iOS(.v16),
.tvOS(.v16),
],
products: [
.library(name: "MVTPostgis", targets: ["MVTPostgis"]),
],
dependencies: [
.package(url: "https://github.com/Outdooractive/mvt-tools", from: "1.3.2"),
.package(url: "https://github.com/Outdooractive/gis-tools", from: "1.2.0"),
.package(url: "https://github.com/Outdooractive/PostgresConnectionPool.git", from: "0.7.0"),
.package(url: "https://github.com/vapor/postgres-nio.git", from: "1.20.2"),
.package(url: "https://github.com/apple/swift-collections", from: "1.1.0"),
.package(url: "https://github.com/yahoojapan/SwiftyXMLParser", from: "5.6.0"),
.package(url: "https://github.com/jpsim/Yams", from: "4.0.6"),
],
targets: [
.target(
name: "MVTPostgis",
dependencies: [
.product(name: "GISTools", package: "gis-tools"),
.product(name: "MVTTools", package: "mvt-tools"),
.product(name: "PostgresConnectionPool", package: "PostgresConnectionPool"),
.product(name: "PostgresNIO", package: "postgres-nio"),
.product(name: "Collections", package: "swift-collections"),
.product(name: "SwiftyXMLParser", package: "SwiftyXMLParser"),
.product(name: "Yams", package: "Yams"),
]),
]
)
67 changes: 67 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FOutdooractive%2Fmvt-postgis%2Fbadge%3Ftype%3Dswift-versions)](https://swiftpackageindex.com/Outdooractive/mvt-postgis)
[![](https://img.shields.io/endpoint?url=https%3A%2F%2Fswiftpackageindex.com%2Fapi%2Fpackages%2FOutdooractive%2Fmvt-postgis%2Fbadge%3Ftype%3Dplatforms)](https://swiftpackageindex.com/Outdooractive/mvt-postgis)

# MVTPostgis

Creates vector tiles from Postgis databases.

## Installation with Swift Package Manager

```swift
dependencies: [
.package(url: "https://github.com/Outdooractive/mvt-postgis", from: "1.0.0"),
],
targets: [
.target(name: "MyTarget", dependencies: [
.product(name: "MVTPostgis", package: "mvt-postgis"),
]),
]
```

## Features

TODO

## Usage

TODO

## Contributing

Please create an issue or open a pull request with a fix

## TODOs and future improvements

- Restart queries after timeout
- Explore ST_AsMVTGeom
- Define a JSON source format
- Documentation (!)
- Tests

## Links

- Libraries
- https://github.com/Outdooractive/gis-tools
- https://github.com/Outdooractive/mvt-tools

- Mapnik Postgis documentation:
- https://github.com/mapnik/mapnik/wiki/PostGIS
- https://github.com/mapnik/mapnik/wiki/OptimizeRenderingWithPostGIS

- Mapnik files:
- https://github.com/mapnik/mapnik/blob/master/test/unit/datasource/postgis.cpp
- https://github.com/mapnik/mapnik/blob/master/plugins/input/postgis/postgis_datasource.cpp

- Other:
- https://github.com/plarson/fluent-postgis
- https://github.com/koher/swift-image
- https://github.com/t-ae/swim
- https://github.com/GEOSwift/GEOSwift

## License

MIT

## Author

Thomas Rasch, Outdooractive
24 changes: 24 additions & 0 deletions Sources/MVTPostgis/Extensions/ArrayExtensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import Foundation

extension Array {

var isNotEmpty: Bool {
!isEmpty
}

/// Adds a new element at the end of the array, if it's not nil.
mutating func append(ifNotNil newElement: Element?) {
guard let element = newElement else { return }
append(element)
}

}

extension Array where Element: Equatable {

/// Removes all occurrences of the given object
mutating func remove(_ element: Element) {
self = filter { $0 != element }
}

}
9 changes: 9 additions & 0 deletions Sources/MVTPostgis/Extensions/DataExtensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Foundation

extension Data {

var asUTF8EncodedString: String? {
String(data: self, encoding: .utf8)
}

}
9 changes: 9 additions & 0 deletions Sources/MVTPostgis/Extensions/DequeExtensions.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import Collections

extension Deque {

var isNotEmpty: Bool {
!isEmpty
}

}
Loading

0 comments on commit 878e988

Please sign in to comment.