-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sf-ios 4.1.4, projection geometry utilities with geodesic path and en…
…velope methods
- Loading branch information
Showing
7 changed files
with
133 additions
and
3 deletions.
There are no files selected for viewing
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
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,43 @@ | ||
// | ||
// SFPProjectionGeometryUtils.h | ||
// sf-proj-ios | ||
// | ||
// Created by Brian Osborn on 3/27/24. | ||
// Copyright © 2024 NGA. All rights reserved. | ||
// | ||
|
||
#import "PROJProjection.h" | ||
#import "SFPoint.h" | ||
|
||
/** | ||
* Projection Geometry Utilities | ||
*/ | ||
@interface SFPProjectionGeometryUtils : NSObject | ||
|
||
/** | ||
* Create a geodesic path of a points in the projection with a max distance | ||
* between any two path points | ||
* | ||
* @param points | ||
* points in the projection | ||
* @param maxDistance | ||
* max distance allowed between path points | ||
* @param projection | ||
* projection of the points | ||
* @return geodesic path of points | ||
*/ | ||
+(NSArray<SFPoint *> *) geodesicPathOfPoints: (NSArray<SFPoint *> *) points withMaxDistance: (double) maxDistance inProjection: (PROJProjection *) projection; | ||
|
||
/** | ||
* Expand the vertical bounds of a geometry envelope in the projection by | ||
* including geodesic bounds | ||
* | ||
* @param envelope | ||
* geometry envelope | ||
* @param projection | ||
* projection of the envelope | ||
* @return geodesic expanded geometry envelope | ||
*/ | ||
+(SFGeometryEnvelope *) geodesicEnvelope: (SFGeometryEnvelope *) envelope inProjection: (PROJProjection *) projection; | ||
|
||
@end |
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,77 @@ | ||
// | ||
// SFPProjectionGeometryUtils.m | ||
// sf-proj-ios | ||
// | ||
// Created by Brian Osborn on 3/27/24. | ||
// Copyright © 2024 NGA. All rights reserved. | ||
// | ||
|
||
#import "SFPProjectionGeometryUtils.h" | ||
#import "PROJProjectionFactory.h" | ||
#import "PROJProjectionConstants.h" | ||
#import "SFPGeometryTransform.h" | ||
#import "SFGeometryUtils.h" | ||
|
||
@implementation SFPProjectionGeometryUtils | ||
|
||
static PROJProjection *WGS_84_PROJECTION = nil; | ||
|
||
+(void) initialize{ | ||
if(WGS_84_PROJECTION == nil){ | ||
WGS_84_PROJECTION = [PROJProjectionFactory projectionWithEpsgInt:PROJ_EPSG_WORLD_GEODETIC_SYSTEM]; | ||
} | ||
} | ||
|
||
+(NSArray<SFPoint *> *) geodesicPathOfPoints: (NSArray<SFPoint *> *) points withMaxDistance: (double) maxDistance inProjection: (PROJProjection *) projection{ | ||
|
||
NSArray<SFPoint *> *geodesicPath = points; | ||
|
||
if(projection != nil){ | ||
|
||
// Reproject to WGS84 if not in degrees | ||
if(![projection isUnit:PROJ_UNIT_DEGREES]){ | ||
SFPGeometryTransform *toWGS84 = [SFPGeometryTransform transformFromProjection:projection andToProjection:WGS_84_PROJECTION]; | ||
geodesicPath = [toWGS84 transformPoints:geodesicPath]; | ||
} | ||
|
||
// Create the geodesic path | ||
geodesicPath = [SFGeometryUtils geodesicPathOfPoints:geodesicPath withMaxDistance:maxDistance]; | ||
|
||
// Reproject back to the original projection | ||
if(![projection isUnit:PROJ_UNIT_DEGREES]){ | ||
SFPGeometryTransform *fromWGS84 = [SFPGeometryTransform transformFromProjection:WGS_84_PROJECTION andToProjection:projection]; | ||
geodesicPath = [fromWGS84 transformPoints:geodesicPath]; | ||
} | ||
|
||
} | ||
|
||
return geodesicPath; | ||
} | ||
|
||
+(SFGeometryEnvelope *) geodesicEnvelope: (SFGeometryEnvelope *) envelope inProjection: (PROJProjection *) projection{ | ||
|
||
SFGeometryEnvelope *geodesic = envelope; | ||
|
||
if(projection != nil){ | ||
|
||
// Reproject to WGS84 if not in degrees | ||
if(![projection isUnit:PROJ_UNIT_DEGREES]){ | ||
SFPGeometryTransform *toWGS84 = [SFPGeometryTransform transformFromProjection:projection andToProjection:WGS_84_PROJECTION]; | ||
geodesic = [toWGS84 transformGeometryEnvelope:geodesic]; | ||
} | ||
|
||
// Expand the envelope for geodesic lines | ||
geodesic = [SFGeometryUtils geodesicEnvelope:geodesic]; | ||
|
||
// Reproject back to the original projection | ||
if(![projection isUnit:PROJ_UNIT_DEGREES]){ | ||
SFPGeometryTransform *fromWGS84 = [SFPGeometryTransform transformFromProjection:WGS_84_PROJECTION andToProjection:projection]; | ||
geodesic = [fromWGS84 transformGeometryEnvelope:geodesic]; | ||
} | ||
|
||
} | ||
|
||
return geodesic; | ||
} | ||
|
||
@end |
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