Skip to content

Commit

Permalink
Merge pull request #33 from ngageoint/develop
Browse files Browse the repository at this point in the history
release 1.2.3
  • Loading branch information
bosborn authored Jul 10, 2017
2 parents fc90e2b + cc418d3 commit 299303d
Show file tree
Hide file tree
Showing 10 changed files with 52 additions and 57 deletions.
8 changes: 5 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ Adheres to [Semantic Versioning](http://semver.org/).

---

## 1.2.3 (TBD)
## [1.2.3](https://github.com/ngageoint/geopackage-ios/releases/tag/1.2.3) (07-10-2017)

* TBD
* Fix bug in feature row enumeration.
* Bug fix for indexed feature row enumeration in optimized release builds
* Improved handling of unknown Contents bounding boxes
* Feature Tiles fix for max feature number drawn tiles on non retina screens
* tiff-ios version updated to 1.0.3

## [1.2.2](https://github.com/ngageoint/geopackage-ios/releases/tag/1.2.2) (06-14-2017)

Expand Down
2 changes: 1 addition & 1 deletion Podfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ inhibit_all_warnings!
target 'geopackage-ios' do
pod 'proj4-ios', '~> 4.9.3'
pod 'wkb-ios', '~> 1.0.7'
pod 'tiff-ios', '~> 1.0.2'
pod 'tiff-ios', '~> 1.0.3'

target 'geopackage-iosTests' do
inherit! :search_paths
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ int featureTileCount = [featureTileGenerator generateTiles];

// Close manager when done
[manager close];

```
### Build ###
Expand Down Expand Up @@ -156,7 +156,7 @@ Pull from [CocoaPods](https://cocoapods.org/pods/geopackage-ios):
Pull from GitHub:
pod 'geopackage-ios', :git => 'https://github.com/ngageoint/geopackage-ios.git', :branch => 'master'
pod 'geopackage-ios', :git => 'https://github.com/ngageoint/geopackage-ios.git', :tag => '1.2.2'
pod 'geopackage-ios', :git => 'https://github.com/ngageoint/geopackage-ios.git', :tag => '1.2.3'
Include as local project:
Expand Down Expand Up @@ -246,7 +246,7 @@ boundingBox = GPKGProjectionTransform.init(fromEpsg: PROJ_EPSG_WORLD_GEODETIC_SY
// URL Tile Generator (generate tiles from a URL)
let urlTileGenerator: GPKGTileGenerator = GPKGUrlTileGenerator(geoPackage: geoPackage, andTableName: "url_tile_table", andTileUrl: "http://url/{z}/{x}/{y}.png", andMinZoom: 2, andMaxZoom: 7, andBoundingBox:boundingBox, andProjection:GPKGProjectionFactory.getProjectionWith(PROJ_EPSG_WEB_MERCATOR));
let urlTileCount: Int32 = urlTileGenerator.generateTiles();
// Feature Tile Generator (generate tiles from features)
let featureTileGenerator: GPKGTileGenerator = GPKGFeatureTileGenerator(geoPackage: geoPackage, andTableName: featureTable + "_tiles", andFeatureTiles: featureTiles, andMinZoom: 10, andMaxZoom: 15, andBoundingBox:boundingBox, andProjection:GPKGProjectionFactory.getProjectionWith(PROJ_EPSG_WEB_MERCATOR));
let featureTileCount: Int32 = featureTileGenerator.generateTiles();
Expand Down
2 changes: 1 addition & 1 deletion geopackage-ios.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ Pod::Spec.new do |s|

s.dependency 'proj4-ios', '~> 4.9.3'
s.dependency 'wkb-ios', '~> 1.0.7'
s.dependency 'tiff-ios', '~> 1.0.2'
s.dependency 'tiff-ios', '~> 1.0.3'
end
6 changes: 5 additions & 1 deletion geopackage-ios/core/contents/GPKGContents.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ -(void) setSrs: (GPKGSpatialReferenceSystem *) srs{
}

-(GPKGBoundingBox *) getBoundingBox{
return[[GPKGBoundingBox alloc] initWithMinLongitude:self.minX andMaxLongitude:self.maxX andMinLatitude:self.minY andMaxLatitude:self.maxY];
GPKGBoundingBox *boundingBox = nil;
if(self.minX != nil && self.maxX != nil && self.minY != nil && self.maxY != nil){
boundingBox = [[GPKGBoundingBox alloc] initWithMinLongitude:self.minX andMaxLongitude:self.maxX andMinLatitude:self.minY andMaxLatitude:self.maxY];
}
return boundingBox;
}

-(void) setBoundingBox: (GPKGBoundingBox *) boundingBox{
Expand Down
12 changes: 7 additions & 5 deletions geopackage-ios/features/user/GPKGFeatureDao.m
Original file line number Diff line number Diff line change
Expand Up @@ -70,13 +70,15 @@ -(GPKGContentsDao *) getContentsDao{
-(GPKGBoundingBox *) getBoundingBox{
GPKGGeometryColumnsDao * geometryColumnsDao = [self getGeometryColumnsDao];
GPKGContents * contents = [geometryColumnsDao getContents:self.geometryColumns];
GPKGContentsDao * contentsDao = [self getContentsDao];
GPKGProjection * contentsProjection = [contentsDao getProjection:contents];

GPKGBoundingBox * boundingBox = [contents getBoundingBox];
if([self.projection.epsg compare:contentsProjection.epsg] != NSOrderedSame){
GPKGProjectionTransform * transform = [[GPKGProjectionTransform alloc] initWithFromProjection:contentsProjection andToProjection:self.projection];
boundingBox = [transform transformWithBoundingBox:boundingBox];
if(boundingBox != nil){
GPKGContentsDao * contentsDao = [self getContentsDao];
GPKGProjection * contentsProjection = [contentsDao getProjection:contents];
if([self.projection.epsg compare:contentsProjection.epsg] != NSOrderedSame){
GPKGProjectionTransform * transform = [[GPKGProjectionTransform alloc] initWithFromProjection:contentsProjection andToProjection:self.projection];
boundingBox = [transform transformWithBoundingBox:boundingBox];
}
}

return boundingBox;
Expand Down
4 changes: 2 additions & 2 deletions geopackage-ios/geopackage.plist
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@
<key>geopackage.number_feature_tiles.text_font</key>
<string>Helvetica</string>
<key>geopackage.number_feature_tiles.text_font_size</key>
<string>7.0</string>
<string>21.0</string>
<key>geopackage.number_feature_tiles.text_color</key>
<dict>
<key>white</key>
Expand Down Expand Up @@ -227,7 +227,7 @@
<string>.062745</string>
</dict>
<key>geopackage.number_feature_tiles.circle_padding_percentage</key>
<string>.1</string>
<string>.4</string>
<key>geopackage.number_feature_tiles.draw_unindexed_tiles</key>
<string>true</string>
<key>geopackage.number_feature_tiles.unindexed_text</key>
Expand Down
18 changes: 10 additions & 8 deletions geopackage-ios/tiles/GPKGTileGenerator.m
Original file line number Diff line number Diff line change
Expand Up @@ -241,14 +241,16 @@ -(void) updateTileBoundsWithTileMatrixSet: (GPKGTileMatrixSet *) tileMatrixSet{
GPKGContentsDao * contentsDao = [self.geoPackage getContentsDao];

GPKGBoundingBox * previousContentsBoundingBox = [contents getBoundingBox];
GPKGProjectionTransform * transformProjectionToContents = [[GPKGProjectionTransform alloc] initWithFromProjection:self.projection andToProjection:[contentsDao getProjection:contents]];
GPKGBoundingBox * contentsBoundingBox = [transformProjectionToContents transformWithBoundingBox:self.boundingBox];
contentsBoundingBox = [GPKGTileBoundingBoxUtils unionWithBoundingBox:contentsBoundingBox andBoundingBox:previousContentsBoundingBox];

// Update the contents if modified
if(![contentsBoundingBox equals:previousContentsBoundingBox]){
[contents setBoundingBox:contentsBoundingBox];
[contentsDao update:contents];
if(previousContentsBoundingBox != nil){
GPKGProjectionTransform * transformProjectionToContents = [[GPKGProjectionTransform alloc] initWithFromProjection:self.projection andToProjection:[contentsDao getProjection:contents]];
GPKGBoundingBox * contentsBoundingBox = [transformProjectionToContents transformWithBoundingBox:self.boundingBox];
contentsBoundingBox = [GPKGTileBoundingBoxUtils unionWithBoundingBox:contentsBoundingBox andBoundingBox:previousContentsBoundingBox];

// Update the contents if modified
if(![contentsBoundingBox equals:previousContentsBoundingBox]){
[contents setBoundingBox:contentsBoundingBox];
[contentsDao update:contents];
}
}

// If updating GeoPackage format tiles, all existing metadata and tile
Expand Down
38 changes: 10 additions & 28 deletions geopackage-ios/tiles/features/custom/GPKGNumberFeaturesTile.m
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ -(instancetype) init{

// Set the default text paint values
self.textFont = [GPKGProperties getValueOfBaseProperty:GPKG_PROP_NUMBER_FEATURE_TILES andProperty:GPKG_PROP_NUMBER_FEATURE_TILES_TEXT_FONT];
self.textFontSize = [[UIScreen mainScreen] scale] * [[GPKGProperties getNumberValueOfBaseProperty:GPKG_PROP_NUMBER_FEATURE_TILES andProperty:GPKG_PROP_NUMBER_FEATURE_TILES_TEXT_FONT_SIZE] floatValue];
self.textFontSize = [[GPKGProperties getNumberValueOfBaseProperty:GPKG_PROP_NUMBER_FEATURE_TILES andProperty:GPKG_PROP_NUMBER_FEATURE_TILES_TEXT_FONT_SIZE] floatValue];
self.textColor = [GPKGUtils getColor:[GPKGProperties getDictionaryValueOfBaseProperty:GPKG_PROP_NUMBER_FEATURE_TILES andProperty:GPKG_PROP_NUMBER_FEATURE_TILES_TEXT_COLOR]];

// Set the default circle values
Expand Down Expand Up @@ -143,37 +143,19 @@ -(UIImage *) drawTileWithTileWidth:(int)tileWidth andTileHeight:(int)tileHeight
}

// Draw the text
CGContextSetTextMatrix(context, CGAffineTransformIdentity);

CGMutablePathRef textPath = CGPathCreateMutable();
CGRect bounds = CGRectMake(centerX - (textSize.width / 2.0), centerY - (textSize.height / 2.0), textSize.width, textSize.height);
CGPathAddRect(textPath, NULL, bounds );

NSMutableAttributedString* attString = [[NSMutableAttributedString alloc] initWithString:text];

NSMutableParagraphStyle *paragraphStyle = [[NSParagraphStyle defaultParagraphStyle] mutableCopy];
paragraphStyle.alignment = NSTextAlignmentCenter;
NSDictionary *attributes = @{
NSFontAttributeName: font,
NSForegroundColorAttributeName: self.textColor,
NSParagraphStyleAttributeName: paragraphStyle,
};

[attString beginEditing];

[attString addAttribute:NSForegroundColorAttributeName value:self.textColor range:NSMakeRange(0, text.length)];
[attString addAttribute:NSFontAttributeName value:font range:NSMakeRange(0, text.length)];
[attString addAttribute:NSParagraphStyleAttributeName value:paragraphStyle range:NSMakeRange(0, text.length)];

[attString endEditing];

CTFramesetterRef textFramesetter =
CTFramesetterCreateWithAttributedString((CFAttributedStringRef)attString);
CTFrameRef textFrame =
CTFramesetterCreateFrame(textFramesetter,
CFRangeMake(0, [attString length]), textPath, NULL);

CTFrameDraw(textFrame, context);

CFRelease(textFrame);
CFRelease(textPath);
CFRelease(textFramesetter);
CGRect bounds = CGRectMake(centerX - (textSize.width / 2.0), centerY - (textSize.height / 2.0), textSize.width, textSize.height);

CGContextTranslateCTM(context, 0, tileHeight);
CGContextScaleCTM(context, 1.0, -1.0);
[text drawInRect:bounds withAttributes:attributes];

UIImage * image = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
Expand Down
13 changes: 8 additions & 5 deletions geopackage-ios/user/GPKGUserDao.m
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,16 @@ -(int) getZoomLevel{
if(self.projection == nil){
[NSException raise:@"No Projection" format:@"No projection was set which is required to determine the zoom level"];
}
int zoomLevel = 0;
GPKGBoundingBox * boundingBox = [self getBoundingBox];
if([self.projection.epsg intValue] == PROJ_EPSG_WORLD_GEODETIC_SYSTEM){
boundingBox = [GPKGTileBoundingBoxUtils boundWgs84BoundingBoxWithWebMercatorLimits:boundingBox];
if(boundingBox != nil){
if([self.projection.epsg intValue] == PROJ_EPSG_WORLD_GEODETIC_SYSTEM){
boundingBox = [GPKGTileBoundingBoxUtils boundWgs84BoundingBoxWithWebMercatorLimits:boundingBox];
}
GPKGProjectionTransform * webMercatorTransform = [[GPKGProjectionTransform alloc] initWithFromProjection:self.projection andToEpsg:PROJ_EPSG_WEB_MERCATOR];
GPKGBoundingBox * webMercatorBoundingBox = [webMercatorTransform transformWithBoundingBox:boundingBox];
zoomLevel = [GPKGTileBoundingBoxUtils getZoomLevelWithWebMercatorBoundingBox:webMercatorBoundingBox];
}
GPKGProjectionTransform * webMercatorTransform = [[GPKGProjectionTransform alloc] initWithFromProjection:self.projection andToEpsg:PROJ_EPSG_WEB_MERCATOR];
GPKGBoundingBox * webMercatorBoundingBox = [webMercatorTransform transformWithBoundingBox:boundingBox];
int zoomLevel = [GPKGTileBoundingBoxUtils getZoomLevelWithWebMercatorBoundingBox:webMercatorBoundingBox];
return zoomLevel;
}

Expand Down

0 comments on commit 299303d

Please sign in to comment.