Skip to content

Commit

Permalink
remove lint warnings in GPXMapView
Browse files Browse the repository at this point in the history
  • Loading branch information
merlos committed Jun 1, 2023
1 parent 130b28c commit 214e15f
Showing 1 changed file with 19 additions and 22 deletions.
41 changes: 19 additions & 22 deletions OpenGpxTracker/GPXMapView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,21 @@ class GPXMapView: MKMapView {
var currentSegmentOverlay: MKPolyline

///
var extent: GPXExtentCoordinates = GPXExtentCoordinates() //extent of the GPX points and tracks
var extent: GPXExtentCoordinates = GPXExtentCoordinates() // Extent of the GPX points and tracks

///position of the compass in the map
///Example:
/// Position of the compass in the map
/// Example:
/// map.compassRect = CGRect(x: map.frame.width/2 - 18, y: 70, width: 36, height: 36)
var compassRect: CGRect

/// Is the map using local image cache??
var useCache: Bool = true { //use tile overlay cache (
var useCache: Bool = true { // Use tile overlay cache (
didSet {
if tileServerOverlay is CachedTileOverlay {
print("GPXMapView:: setting useCache \(useCache)")
// swiftlint:disable force_cast
(tileServerOverlay as! CachedTileOverlay).useCache = useCache
// swiftlint:enable force_cast
}
}
}
Expand All @@ -72,13 +73,13 @@ class GPXMapView: MKMapView {
updateMapInformation(newValue)
// remove current overlay
if tileServer != .apple {
//to see apple maps we need to remove the overlay added by map cache.
// To see apple maps we need to remove the overlay added by map cache.
removeOverlay(tileServerOverlay)
}

//add new overlay to map if not using Apple Maps
// Add new overlay to map if not using Apple Maps
if newValue != .apple && newValue != .appleSatellite {
//Update cacheConfig
// Update cacheConfig
var config = MapCacheConfig(withUrlTemplate: newValue.templateUrl)
config.subdomains = newValue.subdomains
config.tileSize = CGSize(width: newValue.tileSize, height: newValue.tileSize)
Expand All @@ -93,8 +94,7 @@ class GPXMapView: MKMapView {
// we need to keep a reference to remove it, in case we return back to Apple Maps.
//
tileServerOverlay = useCache(cache, canReplaceMapContent: newValue.canReplaceMapContent)
}
else {
} else {
self.mapType = (newValue == .apple) ? .standard : .satellite
}
}
Expand Down Expand Up @@ -130,7 +130,7 @@ class GPXMapView: MKMapView {
/// Initializes the map with an empty currentSegmentOverlay.
///
required init?(coder aDecoder: NSCoder) {
var tmpCoords: [CLLocationCoordinate2D] = [] //init with empty
var tmpCoords: [CLLocationCoordinate2D] = [] // Init with empty
currentSegmentOverlay = MKPolyline(coordinates: &tmpCoords, count: 0)
compassRect = CGRect.init(x: 0, y: 0, width: 36, height: 36)
super.init(coder: aDecoder)
Expand Down Expand Up @@ -257,8 +257,8 @@ class GPXMapView: MKMapView {
let pt = GPXTrackPoint(location: location)
coreDataHelper.add(toCoreData: pt, withTrackSegmentID: session.trackSegments.count)
session.addPointToCurrentTrackSegmentAtLocation(location)
//redrawCurrent track segment overlay
//First remove last overlay, then re-add the overlay updated with the new point
// RedrawCurrent track segment overlay
// First remove last overlay, then re-add the overlay updated with the new point
removeOverlay(currentSegmentOverlay)
currentSegmentOverlay = session.currentSegment.overlay

Expand All @@ -283,7 +283,7 @@ class GPXMapView: MKMapView {
/// Finishes current segment.
///
func finishCurrentSegment() {
startNewTrackSegment() //basically, we need to append the segment to the list of segments
startNewTrackSegment() // Basically, we need to append the segment to the list of segments
}

///
Expand All @@ -295,8 +295,8 @@ class GPXMapView: MKMapView {
removeAnnotations(annotations)
extent = GPXExtentCoordinates()

//add tile server overlay
//by removing all overlays, tile server overlay is also removed. We need to add it back
// Add tile server overlay
// by removing all overlays, tile server overlay is also removed. We need to add it back
if tileServer != .apple {
addOverlayOnBottom(tileServerOverlay)
}
Expand Down Expand Up @@ -344,10 +344,9 @@ class GPXMapView: MKMapView {
session.totalTrackedDistance += oneTrack.length
for segment in oneTrack.segments {
let overlay = segment.overlay
//addOverlay(overlay)
addOverlayOnTop(overlay)
let segmentTrackpoints = segment.points
//add point to map extent
// Add point to map extent
for waypoint in segmentTrackpoints {
extent.extendAreaToIncludeLocation(waypoint.coordinate)
}
Expand All @@ -366,26 +365,24 @@ class GPXMapView: MKMapView {
session.totalTrackedDistance += oneTrack.length
for segment in oneTrack.segments {
let overlay = segment.overlay
//addOverlay(overlay)
addOverlayOnTop(overlay)

let segmentTrackpoints = segment.points
//add point to map extent
// Add point to map extent
for waypoint in segmentTrackpoints {
extent.extendAreaToIncludeLocation(waypoint.coordinate)
}
}
}

// for last session track segment
// For last session track segment
for trackSegment in session.trackSegments {

let overlay = trackSegment.overlay
//addOverlay(overlay)
addOverlayOnTop(overlay)

let segmentTrackpoints = trackSegment.points
//add point to map extent
// Add point to map extent
for waypoint in segmentTrackpoints {
extent.extendAreaToIncludeLocation(waypoint.coordinate)
}
Expand Down

0 comments on commit 214e15f

Please sign in to comment.