<commit_before><commit_msg>Start of README<commit_after># GeoPackage iOS

### GeoPackage iOS Lib ####

The GeoPackage Libraries were developed at the National Geospatial-Intelligence Agency (NGA) in collaboration with [BIT Systems](https://www.bit-sys.com/index.jsp). 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/).

### 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 ###

GeoPackage iOS is a SDK Objective-C implementation of the Open Geospatial Consortium [GeoPackage](http://www.geopackage.org/) [spec](http://www.geopackage.org/spec/).

The GeoPackage SDK provides the ability to manage GeoPackage files providing read, write, import, export, share, and open support. Open GeoPackage files provide read and write access to features and tiles. Feature support includes Well-Known Binary and iOS Map shape translations. Tile generation supports creation by URL or features. Tile providers supporting GeoPackage format, standard tile API, and feature tile generation.

### Usage ###

#### GeoPackage MapCache ####

The [GeoPackage MapCache](https://git.geointapps.org/geopackage/geopackage-sample-ios) app provides an extensive standalone example on how to use the SDK.

#### Example ####

    // Context context = ...;
    // File geoPackageFile = ...;
    // GoogleMap map = ...;
    
    // Get a manager
    GeoPackageManager manager = GeoPackageFactory.getManager(context);
    
    // Available databases
    List<String> databases = manager.databases();
    
    // Import database
    boolean imported = manager.importGeoPackage(geoPackageFile);
    
    // Open database
    GeoPackage geoPackage = manager.open(databases.get(0));
    
    // GeoPackage Table DAOs
    SpatialReferenceSystemDao srsDao = geoPackage.getSpatialReferenceSystemDao();
    ContentsDao contentsDao = geoPackage.getContentsDao();
    GeometryColumnsDao geomColumnsDao = geoPackage.getGeometryColumnsDao();
    TileMatrixSetDao tileMatrixSetDao = geoPackage.getTileMatrixSetDao();
    TileMatrixDao tileMatrixDao = geoPackage.getTileMatrixDao();
    DataColumnsDao dataColumnsDao = geoPackage.getDataColumnsDao();
    DataColumnConstraintsDao dataColumnConstraintsDao = geoPackage.getDataColumnConstraintsDao();
    MetadataDao metadataDao = geoPackage.getMetadataDao();
    MetadataReferenceDao metadataReferenceDao = geoPackage.getMetadataReferenceDao();
    ExtensionsDao extensionsDao = geoPackage.getExtensionsDao();
    
    // Feature and tile tables
    List<String> features = geoPackage.getFeatureTables();
    List<String> tiles = geoPackage.getTileTables();
    
    // Query Features
    String featureTable = features.get(0);
    FeatureDao featureDao = geoPackage.getFeatureDao(featureTable);
    GoogleMapShapeConverter converter = new GoogleMapShapeConverter(
            featureDao.getProjection());
    FeatureCursor featureCursor = featureDao.queryForAll();
    try{
        while(featureCursor.moveToNext()){
            FeatureRow featureRow = featureCursor.getRow();
            GeoPackageGeometryData geometryData = featureRow.getGeometry();
            Geometry geometry = geometryData.getGeometry();
            GoogleMapShape shape = converter.toShape(geometry);
            GoogleMapShape mapShape = GoogleMapShapeConverter
                    .addShapeToMap(map, shape);
            // ...
        }
    }finally{
        featureCursor.close();
    }
    
    // Query Tiles
    String tileTable = tiles.get(0);
    TileDao tileDao = geoPackage.getTileDao(tileTable);
    TileCursor tileCursor = tileDao.queryForAll();
    try{
        while(tileCursor.moveToNext()){
            TileRow tileRow = tileCursor.getRow();
            byte[] tileBytes = tileRow.getTileData();
            Bitmap tileBitmap = tileRow.getTileDataBitmap();
            // ...
        }
    }finally{
        tileCursor.close();
    }
    
    // Tile Provider (GeoPackage or Google API)
    TileProvider overlay = GeoPackageOverlayFactory
            .getTileProvider(tileDao);
    TileOverlayOptions overlayOptions = new TileOverlayOptions();
    overlayOptions.tileProvider(overlay);
    overlayOptions.zIndex(-1);
    map.addTileOverlay(overlayOptions);
    
    // Feature Tile Provider
    FeatureTiles featureTiles = new FeatureTiles(context, featureDao);
    TileProvider featureOverlay = new FeatureOverlay(featureTiles);
    TileOverlayOptions featureOverlayOptions = new TileOverlayOptions();
    featureOverlayOptions.tileProvider(featureOverlay);
    featureOverlayOptions.zIndex(-1);
    map.addTileOverlay(featureOverlayOptions);
    
    // URL Tile Generator
    TileGenerator urlTileGenerator = new UrlTileGenerator(context, geoPackage,
                    "url_tile_table", "http://url/{z}/{x}/{y}.png", 2, 7);
    int urlTileCount = urlTileGenerator.generateTiles();
    
    // Feature Tile Generator
    TileGenerator featureTileGenerator = new FeatureTileGenerator(context, geoPackage,
                    featureTable + "_tiles", featureTiles, 10, 15);
    int featureTileCount = featureTileGenerator.generateTiles();
    
    // Close database when done
    geoPackage.close();

### Build ###

The following repositories must be built first:
* [GeoPackage WKB iOS] (https://git.geointapps.org/geopackage/wkb-ios)

### Remote Dependencies ###

* [WKB](https://git.geointapps.org/geopackage/wkb-ios) (The MIT License (MIT)) - GeoPackage Well Known Binary Lib
* [AFNetworking](https://github.com/AFNetworking/AFNetworking) (The MIT License (MIT)) - Networking framework
* [proj4](https://trac.osgeo.org/proj/) (The MIT License (MIT)) - Cartographic projection software
{'fraction_non_alphanumeric': 0.09056956115779645, 'fraction_numerical': 0.0026455026455026454, 'mean_word_length': 3.7431734317343173, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 6, 'lorem ipsum': 0, 'www.': 3, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '152571', 'n_tokens_mistral': 1713, 'n_tokens_neox': 1665, 'n_words': 501}