Files
Swiftgram/submodules/TelegramCore/Sources/ApiUtils/TelegramMediaMap.swift
Isaac 6b2c0f9c53 Refactor constructor use sites for types 100-119 to struct pattern
Migrated 22 constructors: fileHash, folder, folderPeer, forumTopic,
forumTopicDeleted, foundStory, game, geoPoint, geoPointAddress,
globalPrivacySettings, groupCall, groupCallDiscarded, groupCallDonor,
groupCallMessage, groupCallParticipant, groupCallParticipantVideo,
groupCallParticipantVideoSourceGroup, groupCallStreamChannel,
highScore, importedContact, inlineBotSwitchPM, inlineBotWebView

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
2026-01-16 02:41:47 +08:00

28 lines
1.6 KiB
Swift

import Foundation
import Postbox
import TelegramApi
func telegramMediaMapFromApiGeoPoint(_ geo: Api.GeoPoint, title: String?, address: String?, provider: String?, venueId: String?, venueType: String?, liveBroadcastingTimeout: Int32?, liveProximityNotificationRadius: Int32?, heading: Int32?) -> TelegramMediaMap {
var venue: MapVenue?
if let title = title {
venue = MapVenue(title: title, address: address, provider: provider, id: venueId, type: venueType)
}
switch geo {
case let .geoPoint(geoPointData):
let (_, long, lat, _, accuracyRadius) = (geoPointData.flags, geoPointData.long, geoPointData.lat, geoPointData.accessHash, geoPointData.accuracyRadius)
return TelegramMediaMap(latitude: lat, longitude: long, heading: heading, accuracyRadius: accuracyRadius.flatMap { Double($0) }, venue: venue, liveBroadcastingTimeout: liveBroadcastingTimeout, liveProximityNotificationRadius: liveProximityNotificationRadius)
case .geoPointEmpty:
return TelegramMediaMap(latitude: 0.0, longitude: 0.0, heading: nil, accuracyRadius: nil, venue: venue, liveBroadcastingTimeout: liveBroadcastingTimeout, liveProximityNotificationRadius: liveProximityNotificationRadius)
}
}
func mapGeoAddressFromApiGeoPointAddress(_ geo: Api.GeoPointAddress) -> MapGeoAddress {
switch geo {
case let .geoPointAddress(geoPointAddressData):
let (countryIso2, state, city, street) = (geoPointAddressData.countryIso2, geoPointAddressData.state, geoPointAddressData.city, geoPointAddressData.street)
return MapGeoAddress(country: countryIso2, state: state, city: city, street: street)
}
}