-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
commit da9bff7 Author: Tyler Burgett <[email protected]> Date: Wed Aug 11 13:10:49 2021 -0600 Fix for URL check. Button style changes. Better handling for images when saving attachments to a new point. commit f3c3e62 Author: Tyler Burgett <[email protected]> Date: Mon Jul 5 17:27:27 2021 -0600 Fix for an inconsistancy when saving points to a new feature layer. Added compass mode to the map. Changed the default map pin style to match MAGE. commit 809a613 Author: Tyler Burgett <[email protected]> Date: Fri Jun 18 14:25:40 2021 -0600 Added code for getting and views for viewing attachments for map features. Bug fixes for deleting geopackages, URL validation, checks for geopackages with incorrect SRS IDs. commit 2dd99c2 Author: Tyler Burgett <[email protected]> Date: Thu Apr 15 11:36:09 2021 -0600 Design updates
- Loading branch information
Showing
44 changed files
with
1,216 additions
and
128 deletions.
There are no files selected for viewing
Binary file not shown.
Large diffs are not rendered by default.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
mapcache-ios/Images.xcassets/GPSHeading.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"filename" : "GPS-heading.png", | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"filename" : "[email protected]", | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions
21
mapcache-ios/Images.xcassets/camera.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"filename" : "camera.png", | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
21 changes: 21 additions & 0 deletions
21
mapcache-ios/Images.xcassets/gallery.imageset/Contents.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"images" : [ | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "1x" | ||
}, | ||
{ | ||
"filename" : "gallery.png", | ||
"idiom" : "universal", | ||
"scale" : "2x" | ||
}, | ||
{ | ||
"idiom" : "universal", | ||
"scale" : "3x" | ||
} | ||
], | ||
"info" : { | ||
"author" : "xcode", | ||
"version" : 1 | ||
} | ||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
// | ||
// MCMediaUtility.swift | ||
// mapcache-ios | ||
// | ||
// Created by Tyler Burgett on 4/22/21. | ||
// Copyright © 2021 NGA. All rights reserved. | ||
// | ||
|
||
import Foundation | ||
|
||
|
||
@objc class MCMediaUtility: NSObject { | ||
@objc static let shared = MCMediaUtility() | ||
let manager = GPKGGeoPackageFactory.manager() | ||
let mediaTableName = "gpkg_media" | ||
let idColumnName = "id" | ||
let relatedIdColumnName = "related_id" | ||
let dataColumnName = "data" | ||
let contentTypeColumnName = "content_type" | ||
|
||
private override init() { | ||
super.init() | ||
} | ||
|
||
|
||
@objc func mediaRelationsFor(geoPackageName: String, row:GPKGUserRow) -> [GPKGUserRow] { | ||
let geoPackage = manager?.open(geoPackageName) | ||
let relatedTables = GPKGRelatedTablesExtension.init(geoPackage: geoPackage) | ||
|
||
if (relatedTables?.has() != nil) { | ||
print("Have related tables!") | ||
if let featureDao:GPKGFeatureDao = geoPackage?.featureDao(withTableName: row.tableName()) { | ||
let relationships:[GPKGExtendedRelation] = (relatedTables?.relationships())! | ||
for relationship:GPKGExtendedRelation in relationships { | ||
print("base table name: \(relationship.baseTableName) related table name: \(relationship.relatedTableName) mapping table name: \(relationship.mappingTableName)") | ||
if row.tableName() == relationship.baseTableName && relationship.relatedTableName == self.mediaTableName { | ||
if let mappedIDs = relatedTables?.mappings(for: relationship, withBaseId: row.idValue()) { | ||
if let mediaDao = relatedTables?.mediaDao(for: relationship) { | ||
if let mediaRows = mediaDao.rows(withIds: mappedIDs) { | ||
return mediaRows | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
return [] | ||
} | ||
|
||
|
||
@objc func saveAttachmentsFor(row: GPKGUserRow, media:(NSArray), databaseName:String) { | ||
if let geoPackage = self.manager?.open(databaseName) { | ||
if let relatedTables = GPKGRelatedTablesExtension.init(geoPackage: geoPackage) { | ||
let mappingTableName = row.tableName() + "_" + self.mediaTableName | ||
var mediaTable:GPKGMediaTable = GPKGMediaTable.init() | ||
|
||
if !relatedTables.has() || !geoPackage.isTable(self.mediaTableName) || !geoPackage.isTable(mappingTableName) { | ||
// Create the media table | ||
let columns = NSMutableArray() | ||
|
||
if !geoPackage.isTable(self.mediaTableName) { | ||
mediaTable = GPKGMediaTable.create(with: GPKGMediaTableMetadata.create(withTable: self.mediaTableName, andAdditionalColumns: (columns as! [GPKGUserCustomColumn]))) | ||
} else { | ||
if let mediaDao = relatedTables.mediaDao(forTableName: self.mediaTableName) { | ||
mediaTable = mediaDao.mediaTable() | ||
} | ||
} | ||
|
||
if !geoPackage.isTable(mappingTableName) { | ||
let mappingColumns = NSMutableArray() | ||
let userMappingTable = GPKGUserMappingTable.create(withName: mappingTableName, andAdditionalColumns: (mappingColumns as! [GPKGUserCustomColumn])) | ||
// relate the tables | ||
relatedTables.addMediaRelationship(withBaseTable: row.tableName(), andMediaTable: mediaTable, andUserMappingTable: userMappingTable) | ||
} | ||
} | ||
|
||
if let mediaDao = relatedTables.mediaDao(forTableName: self.mediaTableName) { | ||
// do some saving | ||
for m in media { | ||
if let image:UIImage = (m as? UIImage)?.rotateImage() { | ||
if let data:Data = image.pngData() { | ||
let contentType = "image/png" | ||
var mediaRow:GPKGMediaRow = mediaDao.newRow() | ||
mediaRow.setData(data) | ||
mediaRow.setContentType(contentType) | ||
//mediaRow.setId(NSNumber.init(value: mediaDao.create(mediaRow))) | ||
mediaDao.create(mediaRow) | ||
|
||
let mappingTableName = row.tableName() + "_" + self.mediaTableName | ||
let userMappingDao = relatedTables.mappingDao(forTableName: mappingTableName) | ||
let userMappingRow = userMappingDao?.newRow() | ||
userMappingRow?.setBaseId(row.idValue()) | ||
userMappingRow?.setRelatedId(mediaRow.idValue()) | ||
userMappingDao?.create(userMappingRow) | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
@objc func deleteAttachment(geoPackageName: String, row:GPKGUserRow, mediaRow:GPKGMediaRow) -> Bool { | ||
let geoPackage = manager?.open(geoPackageName) | ||
let relatedTables = GPKGRelatedTablesExtension.init(geoPackage: geoPackage) | ||
|
||
if (relatedTables?.has() != nil) { | ||
print("Have related tables!") | ||
if let featureDao:GPKGFeatureDao = geoPackage?.featureDao(withTableName: row.tableName()) { | ||
let relationships:[GPKGExtendedRelation] = (relatedTables?.relationships())! | ||
for relationship:GPKGExtendedRelation in relationships { | ||
if row.tableName() == relationship.baseTableName { | ||
if let mappedIDs = relatedTables?.mappings(for: relationship, withBaseId: row.idValue()) { | ||
if let mediaDao = relatedTables?.mediaDao(for: relationship) { | ||
return mediaDao.delete(mediaRow) > 0 | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
|
||
return false | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.