{"id":21819951,"url":"https://github.com/ngageoint/mgrs-ios","last_synced_at":"2025-04-14T02:42:23.798Z","repository":{"id":58711880,"uuid":"512830311","full_name":"ngageoint/mgrs-ios","owner":"ngageoint","description":"Military Grid Reference System iOS Library","archived":false,"fork":false,"pushed_at":"2024-04-08T14:23:44.000Z","size":1752,"stargazers_count":11,"open_issues_count":0,"forks_count":5,"subscribers_count":13,"default_branch":"master","last_synced_at":"2025-03-27T16:41:55.330Z","etag":null,"topics":["cocoapods","ios","mgrs","military-grid-reference-system","nga","swift","xcode"],"latest_commit_sha":null,"homepage":"https://ngageoint.github.io/mgrs-ios/","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ngageoint.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-07-11T16:24:51.000Z","updated_at":"2025-01-09T21:22:03.000Z","dependencies_parsed_at":"2024-03-27T16:46:28.722Z","dependency_job_id":"4ec4ef35-e812-4bcd-a92e-78c644d1e358","html_url":"https://github.com/ngageoint/mgrs-ios","commit_stats":{"total_commits":51,"total_committers":2,"mean_commits":25.5,"dds":0.05882352941176472,"last_synced_commit":"6184634a22710f23e00026b93e6d9c09b1029b3b"},"previous_names":[],"tags_count":10,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngageoint%2Fmgrs-ios","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngageoint%2Fmgrs-ios/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngageoint%2Fmgrs-ios/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ngageoint%2Fmgrs-ios/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ngageoint","download_url":"https://codeload.github.com/ngageoint/mgrs-ios/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248560276,"owners_count":21124623,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cocoapods","ios","mgrs","military-grid-reference-system","nga","swift","xcode"],"created_at":"2024-11-27T16:27:23.807Z","updated_at":"2025-04-14T02:42:23.764Z","avatar_url":"https://github.com/ngageoint.png","language":"Swift","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MGRS iOS\n\n#### Military Grid Reference System Lib ####\n\nThe MGRS Library was developed at the [National Geospatial-Intelligence Agency (NGA)](http://www.nga.mil/) in collaboration with [BIT Systems](https://www.caci.com/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](http://choosealicense.com/licenses/mit/).\n\n### Pull Requests ###\nIf 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.\n\nSoftware 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.\n\n### About ###\n\n[MGRS](http://ngageoint.github.io/mgrs-ios/) is a Swift library providing Military Grid Reference System functionality, a geocoordinate standard used by NATO militaries for locating points on Earth.  [MGRS App](https://github.com/ngageoint/mgrs-ios/tree/master/app) is a map implementation utilizing this library.\n\n### Usage ###\n\nView the latest [Appledoc](http://ngageoint.github.io/mgrs-ios/docs/api/)\n\n#### Import ####\n\n```swift\n\nimport mgrs_ios\n\n```\n\n#### Coordinates ####\n\n```swift\n\nlet mgrs = MGRS.parse(\"33XVG74594359\")\nlet point = mgrs.toPoint()\nlet pointMeters = point.toMeters()\nlet utm = mgrs.toUTM()\nlet utmCoordinate = utm.description\nlet point2 = utm.toPoint()\n\nlet mgrs2 = MGRS.parse(\"33X VG 74596 43594\")\n\nlet latitude = 63.98862388\nlet longitude = 29.06755082\nlet point3 = GridPoint(longitude, latitude)\nlet mgrs3 = MGRS.from(point3)\nlet mgrsCoordinate = mgrs3.description\nlet mgrsGZD = mgrs3.coordinate(GridType.GZD)\nlet mgrs100k = mgrs3.coordinate(GridType.HUNDRED_KILOMETER)\nlet mgrs10k = mgrs3.coordinate(GridType.TEN_KILOMETER)\nlet mgrs1k = mgrs3.coordinate(GridType.KILOMETER)\nlet mgrs100m = mgrs3.coordinate(GridType.HUNDRED_METER)\nlet mgrs10m = mgrs3.coordinate(GridType.TEN_METER)\nlet mgrs1m = mgrs3.coordinate(GridType.METER)\n\nlet utm2 = UTM.from(point3)\nlet mgrs4 = utm2.toMGRS()\n\nlet utm3 = UTM.parse(\"18 N 585628 4511322\")\nlet mgrs5 = utm3.toMGRS()\n\n```\n\n#### Tile Overlay ####\n\n```swift\n\n// let mapView: MKMapView = ...\n\n// Tile size determined from display density\nlet tileOverlay = MGRSTileOverlay()\n\n// Manually specify tile size\nlet tileOverlay2 = MGRSTileOverlay(512, 512)\n\n// GZD only grid\nlet gzdTileOverlay = MGRSTileOverlay.createGZD()\n\n// Specified grids\nlet customTileOverlay = MGRSTileOverlay(\n        [GridType.GZD, GridType.HUNDRED_KILOMETER])\n\nmapView.addOverlay(tileOverlay)\n\n```\n\n#### Tile Overlay Options ####\n\n```swift\n\nlet tileOverlay = MGRSTileOverlay()\n\nlet x = 8\nlet y = 12\nlet zoom = 5\n\n// Manually get a tile or draw the tile bitmap\nlet tile = tileOverlay.tile(x, y, zoom)\nlet tileImage = tileOverlay.drawTile(x, y, zoom)\n\nlet latitude = 63.98862388\nlet longitude = 29.06755082\nlet locationCoordinate = CLLocationCoordinate2DMake(latitude, longitude)\n\n// MGRS Coordinates\nlet mgrs = tileOverlay.mgrs(locationCoordinate)\nlet coordinate = tileOverlay.coordinate(locationCoordinate)\nlet zoomCoordinate = tileOverlay.coordinate(locationCoordinate, zoom)\n\nlet mgrsGZD = tileOverlay.coordinate(locationCoordinate, GridType.GZD)\nlet mgrs100k = tileOverlay.coordinate(locationCoordinate, GridType.HUNDRED_KILOMETER)\nlet mgrs10k = tileOverlay.coordinate(locationCoordinate, GridType.TEN_KILOMETER)\nlet mgrs1k = tileOverlay.coordinate(locationCoordinate, GridType.KILOMETER)\nlet mgrs100m = tileOverlay.coordinate(locationCoordinate, GridType.HUNDRED_METER)\nlet mgrs10m = tileOverlay.coordinate(locationCoordinate, GridType.TEN_METER)\nlet mgrs1m = tileOverlay.coordinate(locationCoordinate, GridType.METER)\n\n```\n\n#### Custom Grids ####\n\n```swift\n\nlet grids = Grids()\n\ngrids.setColor(GridType.GZD, UIColor.red)\ngrids.setWidth(GridType.GZD, 5.0)\n\ngrids.setLabelMinZoom(GridType.GZD, 3)\ngrids.setLabelMaxZoom(GridType.GZD, 8)\ngrids.setLabelTextSize(GridType.GZD, 32.0)\n\ngrids.setMinZoom(GridType.HUNDRED_KILOMETER, 4)\ngrids.setMaxZoom(GridType.HUNDRED_KILOMETER, 8)\ngrids.setColor(GridType.HUNDRED_KILOMETER, UIColor.blue)\n\ngrids.setLabelColor(GridType.HUNDRED_KILOMETER, UIColor.orange)\ngrids.setLabelBuffer(GridType.HUNDRED_KILOMETER, 0.1)\n\ngrids.setColor([GridType.TEN_KILOMETER, GridType.KILOMETER, GridType.HUNDRED_METER, GridType.TEN_METER], UIColor.darkGray)\n\ngrids.disable(GridType.METER)\n\ngrids.enableLabeler(GridType.TEN_KILOMETER)\n\nlet tileOverlay = MGRSTileOverlay(grids)\n\n```\n\n#### Draw Tile Template ####\n\n```swift\n\n// let tile: GridTile = ...\n\nlet grids = Grids()\n\nlet zoomGrids = grids.grids(tile.zoom)\nif zoomGrids.hasGrids() {\n\n    let gridRange = GridZones.gridRange(tile.bounds)\n\n    for grid in zoomGrids {\n\n        // draw this grid for each zone\n        for zone in gridRange {\n\n            let lines = grid.lines(tile, zone)\n            if lines != nil {\n                let pixelRange = zone.bounds.pixelRange(tile)\n                for line in lines! {\n                    let pixel1 = line.point1.pixel(tile)\n                    let pixel2 = line.point2.pixel(tile)\n                    // Draw line\n                }\n            }\n\n            let labels = grid.labels(tile, zone)\n            if labels != nil {\n                for label in labels! {\n                    let pixelRange = label.bounds.pixelRange(tile)\n                    let centerPixel = label.center.pixel(tile)\n                    // Draw label\n                }\n            }\n\n        }\n    }\n}\n\n```\n\n#### Objective-C ####\n\n```objectivec\n\n#import \"mgrs_ios-Swift.h\"\n\n```\n\n```objectivec\n\nMKTileOverlay *tileOverlay = [[MGRSTileOverlay alloc] init];\n[mapView addOverlay:tileOverlay];\n\n```\n\n### Build ###\n\n[![Build \u0026 Test](https://github.com/ngageoint/mgrs-ios/workflows/Build%20\u0026%20Test/badge.svg)](https://github.com/ngageoint/mgrs-ios/actions/workflows/build-test.yml)\n\nBuild this repository using Xcode and/or CocoaPods:\n\n    pod install\n\nOpen mgrs-ios.xcworkspace in Xcode or build from command line:\n\n    xcodebuild -workspace 'mgrs-ios.xcworkspace' -scheme mgrs-ios build\n\nRun tests from Xcode or from command line:\n\n    xcodebuild test -workspace 'mgrs-ios.xcworkspace' -scheme mgrs-ios -destination 'platform=iOS Simulator,name=iPhone 15'\n\n### Include Library ###\n\nInclude this repository by specifying it in a Podfile using a supported option.\n\nPull from [CocoaPods](https://cocoapods.org/pods/mgrs-ios):\n\n    pod 'mgrs-ios', '~\u003e 1.1.6'\n\nPull from GitHub:\n\n    pod 'mgrs-ios', :git =\u003e 'https://github.com/ngageoint/mgrs-ios.git', :branch =\u003e 'master'\n    pod 'mgrs-ios', :git =\u003e 'https://github.com/ngageoint/mgrs-ios.git', :tag =\u003e '1.1.6'\n\nInclude as local project:\n\n    pod 'mgrs-ios', :path =\u003e '../mgrs-ios'\n\n### Remote Dependencies ###\n\n* [Grid](https://github.com/ngageoint/grid-ios) (The MIT License (MIT)) - Grid Library\n\n### MGRS App ###\n\nThe [MGRS App](https://github.com/ngageoint/mgrs-ios/tree/master/app) provides a Military Grid Reference System map using this library.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fngageoint%2Fmgrs-ios","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fngageoint%2Fmgrs-ios","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fngageoint%2Fmgrs-ios/lists"}