Skip to content

Commit

Permalink
Display specific modu berth on map (#8)
Browse files Browse the repository at this point in the history
  • Loading branch information
JoshNels authored Dec 19, 2023
1 parent a99b064 commit 1d91887
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 2 deletions.
20 changes: 19 additions & 1 deletion Marlin/Marlin/DataSources/MODU/Modu+MapImage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,24 @@ extension Modu: MapImage {
static var cacheTiles: Bool = true

func mapImage(marker: Bool, zoomLevel: Int, tileBounds3857: MapBoundingBox?, context: CGContext? = nil) -> [UIImage] {
return defaultMapImage(marker: marker, zoomLevel: zoomLevel, tileBounds3857: tileBounds3857, context: context, tileSize: 512.0)
var images: [UIImage] = []
if let tileBounds3857 = tileBounds3857, distance > 0 {
let circleCoordinates = coordinate.circleCoordinates(radiusMeters: distance * 1852)
let path = UIBezierPath()
var pixel = circleCoordinates[0].toPixel(zoomLevel: zoomLevel, tileBounds3857: tileBounds3857, tileSize: TILE_SIZE)
path.move(to: pixel)
for circleCoordinate in circleCoordinates {
pixel = circleCoordinate.toPixel(zoomLevel: zoomLevel, tileBounds3857: tileBounds3857, tileSize: TILE_SIZE)
path.addLine(to: pixel)
}
path.lineWidth = 4
path.close()
Modu.color.withAlphaComponent(0.3).setFill()
Modu.color.setStroke()
path.fill()
path.stroke()
}
images.append(contentsOf: defaultMapImage(marker: marker, zoomLevel: zoomLevel, tileBounds3857: tileBounds3857, context: context, tileSize: 512.0))
return images
}
}
20 changes: 19 additions & 1 deletion Marlin/Marlin/DataSources/MODU/ModuModel.swift
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,25 @@ extension ModuModel: DataSource {

extension ModuModel: MapImage {
func mapImage(marker: Bool, zoomLevel: Int, tileBounds3857: MapBoundingBox?, context: CGContext?) -> [UIImage] {
return defaultMapImage(marker: marker, zoomLevel: zoomLevel, tileBounds3857: tileBounds3857, context: context, tileSize: 512.0)
var images: [UIImage] = []
if let tileBounds3857 = tileBounds3857, var distance = distance, distance > 0 {
let circleCoordinates = coordinate.circleCoordinates(radiusMeters: distance * 1852)
let path = UIBezierPath()
var pixel = circleCoordinates[0].toPixel(zoomLevel: zoomLevel, tileBounds3857: tileBounds3857, tileSize: TILE_SIZE)
path.move(to: pixel)
for circleCoordinate in circleCoordinates {
pixel = circleCoordinate.toPixel(zoomLevel: zoomLevel, tileBounds3857: tileBounds3857, tileSize: TILE_SIZE)
path.addLine(to: pixel)
}
path.lineWidth = 4
path.close()
Modu.color.withAlphaComponent(0.3).setFill()
Modu.color.setStroke()
path.fill()
path.stroke()
}
images.append(contentsOf: defaultMapImage(marker: marker, zoomLevel: zoomLevel, tileBounds3857: tileBounds3857, context: context, tileSize: 512.0))
return images
}

static var cacheTiles: Bool = true
Expand Down

0 comments on commit 1d91887

Please sign in to comment.