Coder Social home page Coder Social logo

geoswiftmapkit's Introduction

GEOSwift

Swift Package Manager Compatible CocoaPods Compatible Supported Platforms Build Status

Easily handle a geometric object model (points, linestrings, polygons etc.) and related topological operations (intersections, overlapping etc.). A type-safe, MIT-licensed Swift interface to the OSGeo's GEOS library routines.

For MapKit integration visit: https://github.com/GEOSwift/GEOSwiftMapKit
For MapboxGL integration visit: https://github.com/GEOSwift/GEOSwiftMapboxGL

Migrating to Version 5 or Later

Version 5 constitutes a ground-up rewrite of GEOSwift. For full details and help migrating from version 4, see VERSION_5.md.

Features

  • A pure-Swift, type-safe, optional-aware programming interface
  • WKT and WKB reading & writing
  • Robust support for GeoJSON via Codable
  • Thread-safe
  • Swift-native error handling
  • Extensively tested

Requirements

  • iOS 9.0+, tvOS 9.0+, macOS 10.9+, watchOS 2.0+ (Swift Package Manager, CocoaPods)
  • Linux (Swift Package Manager)
  • Swift 5.5

GEOS is licensed under LGPL 2.1 and its compatibility with static linking is at least controversial. Use of geos without dynamic linking is discouraged.

Installation

CocoaPods

  1. Update your Podfile to include:

     use_frameworks!
     pod 'GEOSwift'
    
  2. Run $ pod install

Swift Package Manager

  1. Update the top-level dependencies in your Package.swift to include:

     .package(url: "https://github.com/GEOSwift/GEOSwift.git", from: "10.1.0")
    
  2. Update the target dependencies in your Package.swift to include

     "GEOSwift"
    

In certain cases, you may also need to explicitly include geos as a dependency. See issue #195 for details.

Usage

Geometry creation

// 1. From Well Known Text (WKT) representation
let point = try Point(wkt: "POINT(10 45)")
let polygon = try Geometry(wkt: "POLYGON((35 10, 45 45.5, 15 40, 10 20, 35 10),(20 30, 35 35, 30 20, 20 30))")

// 2. From a Well Known Binary (WKB)
let wkb: NSData = geometryWKB()
let geometry2 = try Geometry(wkb: wkb)

// 3. From a GeoJSON file:
let decoder = JSONDecoder()
if let geoJSONURL = Bundle.main.url(forResource: "multipolygon", withExtension: "geojson"),
    let data = try? Data(contentsOf: geoJSONURL),
    let geoJSON = try? decoder.decode(GeoJSON.self, from: data),
    case let .feature(feature) = geoJSON,
    let italy = feature.geometry
{
    italy
}

Topological operations

Let's say we have two geometries:

Example geometries

GEOSwift let you perform a set of operations on these two geometries:

Topological operations

Predicates:

  • equals: returns true if this geometric object is “spatially equal” to another geometry.
  • disjoint: returns true if this geometric object is “spatially disjoint” from another geometry.
  • intersects: returns true if this geometric object “spatially intersects” another geometry.
  • touches: returns true if this geometric object “spatially touches” another geometry.
  • crosses: returns true if this geometric object “spatially crosses’ another geometry.
  • within: returns true if this geometric object is “spatially within” another geometry.
  • contains: returns true if this geometric object “spatially contains” another geometry.
  • overlaps: returns true if this geometric object “spatially overlaps” another geometry.
  • relate: returns true if this geometric object is spatially related to another geometry by testing for intersections between the interior, boundary and exterior of the two geometric objects as specified by the values in the intersectionPatternMatrix.

Playground

Explore more, interactively, in the playground, which is available in the GEOSwiftMapKit project. It can be found inside GEOSwiftMapKit workspace. Open the workspace in Xcode, build the GEOSwiftMapKit framework and open the playground file.

Playground

Contributing

To make a contribution:

  • Fork the repo
  • Start from the main branch and create a branch with a name that describes your contribution
  • Run $ xed Package.swift to open the project in Xcode.
  • Run $ swiftlint from the repo root and resolve any issues.
  • Push your branch and create a pull request to main
  • One of the maintainers will review your code and may request changes
  • If your pull request is accepted, one of the maintainers should update the changelog before merging it

Maintainer

Past Maintainers

License

  • GEOSwift was released by Andrea Cremaschi (@andreacremaschi) under a MIT license. See LICENSE for more information.
  • GEOS stands for Geometry Engine - Open Source, and is a C++ library, ported from the Java Topology Suite. GEOS implements the OpenGIS Simple Features for SQL spatial predicate functions and spatial operators. GEOS, now an OSGeo project, was initially developed and maintained by Refractions Research of Victoria, Canada.

geoswiftmapkit's People

Contributors

macdrevx avatar pjleonard37 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

geoswiftmapkit's Issues

SPM - IPA processing error

Our builds no longer upload to the AppStore. The build remains "processing" on the AppStore (for more than a week). We have a similar problem with distributing AD HOC builds.

ipatool failed with an exception: #<CmdSpec::NonZeroExitException:

In the pipeline logs I find this:

    Ld: cd /var/folders/0l/yh2s2_ld48n32kxxldfht02h0000gn/T/tempaiweugcw
     ['/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld', '-arch', 'arm64', '-r', '-platform_version', 'iOS', '10.0', '13.7', '-no_objc_category_merging', '-syslibroot', '/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.4.sdk', '-sdk_version', '13.7', '-filelist', '/private/var/folders/0l/yh2s2_ld48n32kxxldfht02h0000gn/T/tempbu90v7w8/718.o.LinkFileList', '-ignore_auto_link', '-allow_dead_duplicates', '/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/lib/darwin/libclang_rt.ios.a', '-o', '/private/var/folders/0l/yh2s2_ld48n32kxxldfht02h0000gn/T/tempbu90v7w8/718.o']
    -= Output =-
    ld: warning: -sdk_version and -platform_version are not compatible, ignoring -sdk_version
    Exited with 0
    
    Command took 0 seconds
    Found framework/dylib: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.4.sdk/usr/lib/libc++.1.tbd
    Found framework/dylib: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.4.sdk/System/Library/Frameworks/UIKit.framework/UIKit.tbd
    Found framework/dylib: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.4.sdk/System/Library/Frameworks/Security.framework/Security.tbd
    Found framework/dylib: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.4.sdk/usr/lib/libsqlite3.tbd
    Found framework/dylib: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.4.sdk/usr/lib/libz.1.tbd
    Found framework/dylib: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.4.sdk/System/Library/Frameworks/StoreKit.framework/StoreKit.tbd
    Found framework/dylib: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.4.sdk/System/Library/Frameworks/SystemConfiguration.framework/SystemConfiguration.tbd
    Found framework/dylib: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.4.sdk/System/Library/Frameworks/CoreTelephony.framework/CoreTelephony.tbd
    Found framework/dylib: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.4.sdk/System/Library/Frameworks/Accelerate.framework/Accelerate.tbd
    Found framework/dylib: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.4.sdk/System/Library/Frameworks/CoreData.framework/CoreData.tbd
    Found framework/dylib: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.4.sdk/System/Library/Frameworks/CoreGraphics.framework/CoreGraphics.tbd
    Found framework/dylib: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.4.sdk/System/Library/Frameworks/CoreImage.framework/CoreImage.tbd
    Found framework/dylib: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.4.sdk/System/Library/Frameworks/CoreLocation.framework/CoreLocation.tbd
    Found framework/dylib: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.4.sdk/System/Library/Frameworks/CoreText.framework/CoreText.tbd
    Found framework/dylib: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.4.sdk/System/Library/Frameworks/GLKit.framework/GLKit.tbd
    Found framework/dylib: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.4.sdk/System/Library/Frameworks/ImageIO.framework/ImageIO.tbd
    Found framework/dylib: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.4.sdk/System/Library/Frameworks/OpenGLES.framework/OpenGLES.tbd
    Found framework/dylib: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.4.sdk/System/Library/Frameworks/QuartzCore.framework/QuartzCore.tbd
    Search Path: /var/folders/0l/yh2s2_ld48n32kxxldfht02h0000gn/T/ipatool20210215-23648-fxa81r/thinned-out/arm64/Payload/Parking4411.app/Frameworks, /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/clang/12.0.0/lib/darwin, /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/iphoneos, /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.4.sdk/usr/lib, /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS14.4.sdk/System/Library/Frameworks
    geos not found in dylib search path

Stderr:

>
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:373:in `run'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2808:in `block in CompileOrStripBitcodeInBundle'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2747:in `each'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2747:in `CompileOrStripBitcodeInBundle'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:3016:in `block in ProcessIPA'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2978:in `each'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:2978:in `ProcessIPA'
    /Applications/Xcode.app/Contents/Developer/usr/bin/ipatool:3928:in `<main>'";
            info =             {
            };
            level = ERROR;
            type = exception;
        }
    );
}

It looks liks the geos integration with Swift Package Manager is not going correctly. Any hints?

Update GEOSwift dependency to 9.0.0

Hello folks, latest version of GEOSwift has been 9.0.0 for a year now, wondering if there is any reason not to update dependency of this pod to that version. Currently using GEOSwiftMapKit locks you on 8.x.x. Cheers!

Add support for GEOSwift 5.1

When CocoaPods tries to install the library, the following message is displayed:

[!] CocoaPods could not find compatible versions for pod "GEOSwift":
In snapshot (Podfile.lock):
GEOSwift (= 5.1.0)

In Podfile:
GEOSwift

GEOSwiftMapKit was resolved to 1.0.0, which depends on
  GEOSwift (= 5.0.0)

PS: The CocoaPods version is 1.8.3

Restore quick look tests

#17 deleted the quick look tests due to an issue with either xcodebuild or GH Actions. A reproducible test case has been created at https://github.com/macdrevx/ActionsErrorDemo and bugs are open with both GitHub and Apple.

Here's a summary of the bug:

Title

xcodebuild fails with error "Error deleting scheme: Cannot modify data because the process disallows saving"

Environment

Xcode 14.2

Description

I've run into a peculiar issue with building a Swift package with xcodebuild. I've only been able to repro when running the build on GitHub Actions. Example:

https://github.com/macdrevx/ActionsErrorDemo/actions/runs/4507794222/jobs/7935907313

https://github.com/macdrevx/ActionsErrorDemo is a minimal Swift package that depends on another minimal Swift package https://github.com/macdrevx/ActionsErrorDemoDependency

The only interesting thing about either package is that the test target for ActionsErrorDemo contains some image resources.

The necessary conditions to repro the bug seem to include:

  1. Have a dependency
  2. Have bundled resources
  3. Build in GitHub Actions with the standard xcodebuild invocation: $ xcodebuild -scheme ActionsErrorDemo -sdk "${{ matrix.sdk }}" -destination "${{ matrix.destination }}" clean test

Compiling error when enabling Mac Catalyst in iOS target

To reproduce:

  • In Xcode project target, enable Mac Catalyst
  • Compile a project that imports GEOSwift.

In file GeoSwift+MapKitQuickLook the compiler fails this with message "'Polygon' is ambiguous for type lookup in this context"

once in
extension Polygon.LinearRing: GEOSwiftQuickLook {

and once in
extension Polygon: GEOSwiftQuickLook {

image not found when installed via SwiftPM

Split out from #4

Just tried adding GEOSwiftMapKit to my Xcode iOS project via Xcode SwiftPM integration, and it failed when I try to run:

dyld: Library not loaded: @rpath/libgeos.dylib
  Referenced from: /private/var/containers/Bundle/Application/[REDACTED]/[REDACTED].app/[REDACTED]
  Reason: image not found
(lldb) 

Versions:

image

Those are figured out by Swift PM itself.

And it works charmingly on simulator, but only leaves such an error on application starting when tested on an actual device.

The Playground quicklook zoom is to low

When previewing small polygons (one or two blocks), the zoom level of the map is to high, the polygons are really small, how is the zoom level calculated ? Is there a way to improve it ?

Playground not building

Relatively new to swift development so I apologize in advance if I am missing info or made a glaring mistake. I am currently trying to integrate GEOSwiftMapKit into an existing project. Before fully adopting it I was hoping to utilize the given playground but I cannot get it to build correctly in Xcode.

Swift --version
Apple Swift version 5.4.2 (swiftlang-1205.0.28.2 clang-1205.0.19.57) Target: arm64-apple-darwin20.6.0

xed --version
xed version 12.5.1

M1 Mac mini

Steps I took:

  1. Cloned repository

  2. opened with xed Package.swift

  3. No scheme was present to build for

  4. When opening playground I get a No Such module geoswift exists

  5. Package dependencies do show up
    image

  6. Opened by selecting the GEOSwiftMapkit.xcodeproj file

  7. GEOSwiftMapKit-ios scheme does show up

  8. Received errors below
    image

  9. Added package dependencies for GEOSwift and geos but the framework errors persisted.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.