Skip to content

Commit

Permalink
chore: clean up naming, update license header
Browse files Browse the repository at this point in the history
  • Loading branch information
hansemannn committed Jan 30, 2024
1 parent f54bb2c commit 216e7cf
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 22 deletions.
12 changes: 6 additions & 6 deletions ios/Classes/TiCutoutCircle.h
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//
// TiCutoutCircle.h
// map
//
// Created by Hans Knöchel on 30.01.24.
//
/**
* Titanium SDK
* Copyright TiDev, Inc. 04/07/2022-Present. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/

#import <MapKit/MapKit.h>

Expand Down
12 changes: 6 additions & 6 deletions ios/Classes/TiCutoutCircle.m
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
//
// TiCutoutCircle.m
// map
//
// Created by Hans Knöchel on 30.01.24.
//
/**
* Titanium SDK
* Copyright TiDev, Inc. 04/07/2022-Present. All Rights Reserved.
* Licensed under the terms of the Apache Public License
* Please see the LICENSE included with this distribution for details.
*/

#import "TiCutoutCircle.h"

Expand Down
2 changes: 1 addition & 1 deletion ios/Classes/TiMapUtils.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

+ (MKLocalSearchCompleterResultType)mappedResultTypes:(NSArray<NSNumber *> *)inputResultTypes;

+ (NSArray<NSDictionary *> *)makeCircleCoordinates:(CLLocationCoordinate2D)coordinate withRadius:(double)radius andTolerance:(double)tolerance;
+ (NSArray<NSDictionary *> *)generateCircleCoordinates:(CLLocationCoordinate2D)coordinate withRadius:(double)radius andTolerance:(double)tolerance;

+ (CLLocationCoordinate2D)processLocation:(id)locObj;

Expand Down
2 changes: 1 addition & 1 deletion ios/Classes/TiMapUtils.m
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ + (MKLocalSearchCompleterResultType)mappedResultTypes:(NSArray<NSNumber *> *)inp
return resultTypes;
}

+ (NSArray<NSDictionary *> *)makeCircleCoordinates:(CLLocationCoordinate2D)coordinate withRadius:(double)radius andTolerance:(double)tolerance
+ (NSArray<NSDictionary *> *)generateCircleCoordinates:(CLLocationCoordinate2D)coordinate withRadius:(double)radius andTolerance:(double)tolerance
{
NSMutableArray<NSDictionary *> *coordinates = [[NSMutableArray alloc] init];
double latRadian = coordinate.latitude * M_PI / 180.0;
Expand Down
15 changes: 9 additions & 6 deletions ios/Classes/TiMapViewProxy.m
Original file line number Diff line number Diff line change
Expand Up @@ -300,7 +300,7 @@ - (void)addCutoutCircle:(id)arg

CGFloat latitude = [TiUtils floatValue:@"latitude" properties:arg];
CGFloat longitude = [TiUtils floatValue:@"longitude" properties:arg];
double radius = [TiUtils doubleValue:@"radius" properties:arg];
CGFloat radius = [TiUtils doubleValue:@"radius" properties:arg];
double tolerance = [TiUtils doubleValue:@"tolerance" properties:arg def:3.0];

CLLocationCoordinate2D WORLD_COORDINATES[6];
Expand All @@ -312,18 +312,21 @@ - (void)addCutoutCircle:(id)arg
WORLD_COORDINATES[5] = CLLocationCoordinate2DMake(90, -180);

CLLocationCoordinate2D coordinate = CLLocationCoordinate2DMake(latitude, longitude);
NSArray<NSDictionary *> *circleCoordinates = [TiMapUtils makeCircleCoordinates:coordinate withRadius:radius andTolerance:tolerance];
NSArray<NSDictionary *> *circleCoordinates = [TiMapUtils generateCircleCoordinates:coordinate
withRadius:radius
andTolerance:tolerance];

CLLocationCoordinate2D *circleCoordinatesNative = malloc(sizeof(CLLocationCoordinate2D) * [circleCoordinates count]);

for (int i = 0; i < [circleCoordinates count]; ++i) {
for (NSUInteger i = 0; i < [circleCoordinates count]; ++i) {
CLLocationCoordinate2D coordinate = [TiMapUtils processLocation:[circleCoordinates objectAtIndex:i]];
circleCoordinatesNative[i] = coordinate;
}

MKPolygon *polygon1 = [MKPolygon polygonWithCoordinates:circleCoordinatesNative count:circleCoordinates.count];
TiCutoutCircle *polygon2 = [TiCutoutCircle polygonWithCoordinates:WORLD_COORDINATES count:6 interiorPolygons:@[ polygon1 ]];
MKPolygon *circlePolygon = [MKPolygon polygonWithCoordinates:circleCoordinatesNative count:circleCoordinates.count];
TiCutoutCircle *cutoutPolygon = [TiCutoutCircle polygonWithCoordinates:WORLD_COORDINATES count:6 interiorPolygons:@[ circlePolygon ]];

[[(TiMapView *)[self view] map] addOverlay:polygon2];
[[(TiMapView *)[self view] map] addOverlay:cutoutPolygon];
}

- (void)setAnnotations:(id)arg
Expand Down
4 changes: 2 additions & 2 deletions ios/map.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,8 @@
DB07496D1E081A6A009D8A71 /* Circle */ = {
isa = PBXGroup;
children = (
3A699AC72B68CB0E00938935 /* TiCutoutCircle.h */,
3A699AC82B68CB0E00938935 /* TiCutoutCircle.m */,
27A609EB19F5B84000CA150A /* TiMapCircleProxy.m */,
27A609ED19F5B85900CA150A /* TiMapCircleProxy.h */,
);
Expand All @@ -269,8 +271,6 @@
DB0CCA022010841A00597F24 /* Pattern */,
DB07496B1E081A36009D8A71 /* Polygon */,
DB07496A1E081A23009D8A71 /* Polyline */,
3A699AC72B68CB0E00938935 /* TiCutoutCircle.h */,
3A699AC82B68CB0E00938935 /* TiCutoutCircle.m */,
);
name = Overlays;
sourceTree = "<group>";
Expand Down

0 comments on commit 216e7cf

Please sign in to comment.