Giter VIP home page Giter VIP logo

projections-ios's Introduction

Projections iOS

Projections Lib

The Projections Library was developed at the National Geospatial-Intelligence Agency (NGA) in collaboration with BIT Systems. The government has "unlimited rights" and is releasing this software to increase the impact of government investments by providing developers with the opportunity to take things in new directions. The software use, modification, and distribution rights are stipulated within the MIT license.

Pull Requests

If you'd like to contribute to this project, please make a pull request. We'll review the pull request and discuss the changes. All pull request contributions to this project will be released under the MIT license.

Software source code previously released under an open source license and then modified by NGA staff is considered a "joint work" (see 17 USC § 101); it is partially copyrighted, partially public domain, and as a whole is protected by the copyrights of the non-government authors and must be released according to the terms of the original open source license.

About

Projections is an iOS library for performing projection conversions between coordinates.

For conversions between geometries, see Simple Features Projections.

Usage

View the latest Appledoc

// CLLocationCoordinate2D coordinate = ...

PROJProjection *projection1 = [PROJProjectionFactory projectionWithAuthority:PROJ_AUTHORITY_EPSG
                                                                  andIntCode:PROJ_EPSG_WEB_MERCATOR];
PROJProjection *projection2 = [PROJProjectionFactory projectionWithName:@"EPSG:4326"];
NSString *params = @"+proj=tmerc +lat_0=0 +lon_0=121 +k=0.99995 +x_0=500000 +y_0=0 +ellps=clrk66 +towgs84=-127.62,-67.24,-47.04,-3.068,4.903,1.578,-1.06 +units=m +no_defs";
PROJProjection *projection3 = [PROJProjectionFactory projectionWithAuthority:PROJ_AUTHORITY_EPSG
                                                                  andIntCode:3123
                                                                   andParams:params];
NSMutableString *definition = [NSMutableString string];
[definition appendString:@"PROJCS[\"Lambert_Conformal_Conic (1SP)\","];
[definition appendString:@"GEODCRS[\"GCS_North_American_1983\","];
[definition appendString:@"DATUM[\"North_American_Datum_1983\","];
[definition appendString:@"SPHEROID[\"GRS_1980\",6371000,0]],"];
[definition appendString:@"PRIMEM[\"Greenwich\",0],"];
[definition appendString:@"UNIT[\"Degree\",0.017453292519943295]],"];
[definition appendString:@"PROJECTION[\"Lambert_Conformal_Conic_1SP\"],"];
[definition appendString:@"PARAMETER[\"latitude_of_origin\",25],"];
[definition appendString:@"PARAMETER[\"central_meridian\",-95],"];
[definition appendString:@"PARAMETER[\"scale_factor\",1],"];
[definition appendString:@"PARAMETER[\"false_easting\",0],"];
[definition appendString:@"PARAMETER[\"false_northing\",0],"];
[definition appendString:@"PARAMETER[\"standard_parallel_1\",25],"];
[definition appendString:@"UNIT[\"Meter\",1],AUTHORITY[\"EPSG\",\"9801\"]]"];
PROJProjection *projection4 = [PROJProjectionFactory projectionByDefinition:definition];

PROJProjectionTransform *transform = [projection1 transformationWithProjection:projection2];
PROJProjectionTransform *inverseTransform = [transform inverseTransformation];

CLLocationCoordinate2D transformed = [transform transform:coordinate];
CLLocationCoordinate2D inverseTransformed = [inverseTransform transform:transformed];

[transform destroy];
[inverseTransform destroy];

Build

Build & Test

IMPORTANT - Be sure your Mac has the autoconf, automake, and glibtoolize utilities. These are required to build the PROJ dependency. Without them, pod install will fail. The easiest way to get these is to brew install them:

brew install automake
brew install libtool

Build this repository using Xcode and/or CocoaPods:

pod repo update
pod install

Open proj-ios.xcworkspace in Xcode or build from command line:

xcodebuild -workspace 'proj-ios.xcworkspace' -scheme proj-ios build

Run tests from Xcode or from command line:

xcodebuild test -workspace 'proj-ios.xcworkspace' -scheme proj-ios -destination 'platform=iOS Simulator,name=iPhone 15'

Include Library

See the above note about automake and glibtoolize.

Include this repository by specifying it in a Podfile using a supported option.

Pull from CocoaPods:

pod 'proj-ios', '~> 2.0.3'

If you use use_modular_headers! in your Podfile, disable modular headers for the PROJ dependency:

pod 'proj-ios', '~> 2.0.3'
pod 'PROJ', :modular_headers => false

Pull from GitHub:

pod 'proj-ios', :git => 'https://github.com/ngageoint/projections-ios.git', :branch => 'master'
pod 'proj-ios', :git => 'https://github.com/ngageoint/projections-ios.git', :tag => '2.0.3'

Include as local project:

pod 'proj-ios', :path => '../projections-ios'

Swift

To use from Swift, import the proj-ios bridging header from the Swift project's bridging header

#import "proj-ios-Bridging-Header.h"
// CLLocationCoordinate2D coordinate = ...

let projection1 : PROJProjection = PROJProjectionFactory.projection(withAuthority: PROJ_AUTHORITY_EPSG, andIntCode: PROJ_EPSG_WEB_MERCATOR)
let projection2 : PROJProjection = PROJProjectionFactory.projection(withName: "EPSG:4326")
let projection3 : PROJProjection = PROJProjectionFactory.projection(withAuthority: PROJ_AUTHORITY_EPSG, andIntCode: 3123,
    andParams: "+proj=tmerc +lat_0=0 +lon_0=121 +k=0.99995 +x_0=500000 +y_0=0 +ellps=clrk66 "
        + "+towgs84=-127.62,-67.24,-47.04,-3.068,4.903,1.578,-1.06 +units=m +no_defs")
let projection4 : PROJProjection = PROJProjectionFactory.projection(byDefinition: "PROJCS[\"Lambert_Conformal_Conic (1SP)\","
    + "GEODCRS[\"GCS_North_American_1983\","
    + "DATUM[\"North_American_Datum_1983\","
    + "SPHEROID[\"GRS_1980\",6371000,0]],"
    + "PRIMEM[\"Greenwich\",0],"
    + "UNIT[\"Degree\",0.017453292519943295]],"
    + "PROJECTION[\"Lambert_Conformal_Conic_1SP\"],"
    + "PARAMETER[\"latitude_of_origin\",25],"
    + "PARAMETER[\"central_meridian\",-95],"
    + "PARAMETER[\"scale_factor\",1],"
    + "PARAMETER[\"false_easting\",0],"
    + "PARAMETER[\"false_northing\",0],"
    + "PARAMETER[\"standard_parallel_1\",25],"
    + "UNIT[\"Meter\",1],AUTHORITY[\"EPSG\",\"9801\"]]")

let transform : PROJProjectionTransform = projection1.transformation(with: projection2)
let inverseTransform : PROJProjectionTransform = transform.inverseTransformation()

let transformed : CLLocationCoordinate2D = transform.transform(coordinate)
let inverseTransformed : CLLocationCoordinate2D = inverseTransform.transform(transformed)

transform.destroy()
inverseTransform.destroy()

Remote Dependencies

projections-ios's People

Contributors

bosborn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

projections-ios's Issues

Documentation for build dependencies

Thanks for this project!

The Pod requires GNU build dependencies to install, namely aclocal, autoheader and libtoolize:

Installing crs-ios (1.0.4)
Installing proj-ios (1.0.4)
Installing proj4-ios (4.9.3)
[!] /bin/bash -c 
set -e
./autogen.sh
./configure

Running aclocal

  Something went wrong, giving up!

./autogen.sh: line 29: aclocal: command not found

I installed them using Homebrew (suitably neutered to prevent it breaking stuff as per):

HOMEBREW_NO_AUTO_UPDATE=1 brew install --build-from-source automake libtool

and the Pod then built successfully. It would be good to mention these dependencies in the README.

Build Failed

I'm not able to build the project after installing proj-ios version 2.0.2

Version Information:

  • Projections iOS Version: 2.0.2
  • Projections iOS Source: CocoaPods
  • CocoaPods Version: 1.14.3
  • Xcode Version: 15.3
  • Device or Emulator: Emulator
  • iOS Version: 17.4
  • Other Relevant Libraries:

Expected Results:

  • Build successfully

Observed Results:

  • Build failed

Output:

Screenshot 2024-03-22 at 10 09 15 Screenshot 2024-03-22 at 10 09 36 Screenshot 2024-03-22 at 10 09 47

build fail:PROJCRSParser.h:9:9: fatal error: 'proj_api.h' file not found

Version Information:

  • Projections iOS Version: 1.0.5
  • Projections iOS Source: CocoaPods
  • CocoaPods Version:1.11.3
  • Xcode Version:14.2.0
  • Device or Emulator:
  • iOS Version:
  • Other Relevant Libraries:

brew install automake
brew install libtool
pod repo update
pod install

xcodebuild -workspace 'proj-ios.xcworkspace' -scheme proj-ios build

proj-ios/PROJCRSParser.h:9:9: fatal error: 'proj_api.h' file not found
#import "proj_api.h"
^~~~~~~~~~~~
1 error generated.

** BUILD FAILED **

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.