feat: Add Intaleq Native Android Kotlin & iOS Swift SDKs, Incline slope routing, Topographic contours and modular tactical app
This commit is contained in:
@@ -0,0 +1,241 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
import CoreLocation
|
||||
|
||||
// ─────────────────────────────────────────────────────────────
|
||||
// ID Types (Matching Flutter SDK & Google Maps iOS SDK)
|
||||
// ─────────────────────────────────────────────────────────────
|
||||
|
||||
public struct InlqMarkerId: Hashable, Equatable, Codable {
|
||||
public let value: String
|
||||
public init(_ value: String) { self.value = value }
|
||||
}
|
||||
|
||||
public struct InlqPolylineId: Hashable, Equatable, Codable {
|
||||
public let value: String
|
||||
public init(_ value: String) { self.value = value }
|
||||
}
|
||||
|
||||
public struct InlqPolygonId: Hashable, Equatable, Codable {
|
||||
public let value: String
|
||||
public init(_ value: String) { self.value = value }
|
||||
}
|
||||
|
||||
public struct InlqCircleId: Hashable, Equatable, Codable {
|
||||
public let value: String
|
||||
public init(_ value: String) { self.value = value }
|
||||
}
|
||||
|
||||
/**
|
||||
* An immutable struct representing a latitude/longitude bounding box.
|
||||
*/
|
||||
public struct InlqLatLngBounds: Equatable, Codable {
|
||||
public let southwest: InlqLatLng
|
||||
public let northeast: InlqLatLng
|
||||
|
||||
public init(southwest: InlqLatLng, northeast: InlqLatLng) {
|
||||
self.southwest = southwest
|
||||
self.northeast = northeast
|
||||
}
|
||||
|
||||
public func contains(_ point: InlqLatLng) -> Bool {
|
||||
let inLat = point.latitude >= southwest.latitude && point.latitude <= northeast.latitude
|
||||
let inLng = point.longitude >= southwest.longitude && point.longitude <= northeast.longitude
|
||||
return inLat && inLng
|
||||
}
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────
|
||||
// Bitmap & InfoWindow Types
|
||||
// ─────────────────────────────────────────────────────────────
|
||||
|
||||
public class InlqBitmap {
|
||||
public enum BitmapType {
|
||||
case defaultMarker
|
||||
case defaultMarkerWithHue(CGFloat)
|
||||
case image(UIImage)
|
||||
case asset(String)
|
||||
}
|
||||
|
||||
public let type: BitmapType
|
||||
|
||||
public init(type: BitmapType) {
|
||||
self.type = type
|
||||
}
|
||||
|
||||
public static let defaultMarker = InlqBitmap(type: .defaultMarker)
|
||||
|
||||
public static func defaultMarker(withHue hue: CGFloat) -> InlqBitmap {
|
||||
return InlqBitmap(type: .defaultMarkerWithHue(hue))
|
||||
}
|
||||
|
||||
public static func from(image: UIImage) -> InlqBitmap {
|
||||
return InlqBitmap(type: .image(image))
|
||||
}
|
||||
|
||||
public static func from(assetName: String) -> InlqBitmap {
|
||||
return InlqBitmap(type: .asset(assetName))
|
||||
}
|
||||
}
|
||||
|
||||
public struct InlqInfoWindow {
|
||||
public let title: String?
|
||||
public let snippet: String?
|
||||
public let anchor: CGPoint
|
||||
public let onTap: (() -> Void)?
|
||||
|
||||
public init(title: String? = nil, snippet: String? = nil, anchor: CGPoint = CGPoint(x: 0.5, y: 0.0), onTap: (() -> Void)? = nil) {
|
||||
self.title = title
|
||||
self.snippet = snippet
|
||||
self.anchor = anchor
|
||||
self.onTap = onTap
|
||||
}
|
||||
|
||||
public static let noText = InlqInfoWindow()
|
||||
}
|
||||
|
||||
// ─────────────────────────────────────────────────────────────
|
||||
// Map Overlay Elements (Matching Flutter SDK)
|
||||
// ─────────────────────────────────────────────────────────────
|
||||
|
||||
public class InlqMarker {
|
||||
public let markerId: InlqMarkerId
|
||||
public var position: InlqLatLng
|
||||
public var alpha: CGFloat
|
||||
public var anchor: CGPoint
|
||||
public var isDraggable: Bool
|
||||
public var isFlat: Bool
|
||||
public var icon: InlqBitmap
|
||||
public var infoWindow: InlqInfoWindow
|
||||
public var rotation: Double
|
||||
public var isVisible: Bool
|
||||
public var zIndex: Int32
|
||||
public var onTap: (() -> Void)?
|
||||
|
||||
public init(
|
||||
markerId: InlqMarkerId,
|
||||
position: InlqLatLng,
|
||||
alpha: CGFloat = 1.0,
|
||||
anchor: CGPoint = CGPoint(x: 0.5, y: 1.0),
|
||||
isDraggable: Bool = false,
|
||||
isFlat: Bool = false,
|
||||
icon: InlqBitmap = .defaultMarker,
|
||||
infoWindow: InlqInfoWindow = .noText,
|
||||
rotation: Double = 0.0,
|
||||
isVisible: Bool = true,
|
||||
zIndex: Int32 = 0,
|
||||
onTap: (() -> Void)? = nil
|
||||
) {
|
||||
self.markerId = markerId
|
||||
self.position = position
|
||||
self.alpha = alpha
|
||||
self.anchor = anchor
|
||||
self.isDraggable = isDraggable
|
||||
self.isFlat = isFlat
|
||||
self.icon = icon
|
||||
self.infoWindow = infoWindow
|
||||
self.rotation = rotation
|
||||
self.isVisible = isVisible
|
||||
self.zIndex = zIndex
|
||||
self.onTap = onTap
|
||||
}
|
||||
}
|
||||
|
||||
public class InlqPolyline {
|
||||
public let polylineId: InlqPolylineId
|
||||
public var points: [InlqLatLng]
|
||||
public var strokeColor: UIColor
|
||||
public var strokeWidth: CGFloat
|
||||
public var isGeodesic: Bool
|
||||
public var isVisible: Bool
|
||||
public var zIndex: Int32
|
||||
public var onTap: (() -> Void)?
|
||||
|
||||
public init(
|
||||
polylineId: InlqPolylineId,
|
||||
points: [InlqLatLng] = [],
|
||||
strokeColor: UIColor = UIColor(red: 0.0, green: 0.44, blue: 0.89, alpha: 1.0),
|
||||
strokeWidth: CGFloat = 10.0,
|
||||
isGeodesic: Bool = true,
|
||||
isVisible: Bool = true,
|
||||
zIndex: Int32 = 0,
|
||||
onTap: (() -> Void)? = nil
|
||||
) {
|
||||
self.polylineId = polylineId
|
||||
self.points = points
|
||||
self.strokeColor = strokeColor
|
||||
self.strokeWidth = strokeWidth
|
||||
self.isGeodesic = isGeodesic
|
||||
self.isVisible = isVisible
|
||||
self.zIndex = zIndex
|
||||
self.onTap = onTap
|
||||
}
|
||||
}
|
||||
|
||||
public class InlqPolygon {
|
||||
public let polygonId: InlqPolygonId
|
||||
public var points: [InlqLatLng]
|
||||
public var holes: [[InlqLatLng]]
|
||||
public var strokeColor: UIColor
|
||||
public var strokeWidth: CGFloat
|
||||
public var fillColor: UIColor
|
||||
public var isVisible: Bool
|
||||
public var zIndex: Int32
|
||||
public var onTap: (() -> Void)?
|
||||
|
||||
public init(
|
||||
polygonId: InlqPolygonId,
|
||||
points: [InlqLatLng] = [],
|
||||
holes: [[InlqLatLng]] = [],
|
||||
strokeColor: UIColor = UIColor(red: 0.0, green: 0.44, blue: 0.89, alpha: 1.0),
|
||||
strokeWidth: CGFloat = 5.0,
|
||||
fillColor: UIColor = UIColor(red: 0.0, green: 0.44, blue: 0.89, alpha: 0.2),
|
||||
isVisible: Bool = true,
|
||||
zIndex: Int32 = 0,
|
||||
onTap: (() -> Void)? = nil
|
||||
) {
|
||||
self.polygonId = polygonId
|
||||
self.points = points
|
||||
self.holes = holes
|
||||
self.strokeColor = strokeColor
|
||||
self.strokeWidth = strokeWidth
|
||||
self.fillColor = fillColor
|
||||
self.isVisible = isVisible
|
||||
self.zIndex = zIndex
|
||||
self.onTap = onTap
|
||||
}
|
||||
}
|
||||
|
||||
public class InlqCircle {
|
||||
public let circleId: InlqCircleId
|
||||
public var center: InlqLatLng
|
||||
public var radiusMeters: Double
|
||||
public var strokeColor: UIColor
|
||||
public var strokeWidth: CGFloat
|
||||
public var fillColor: UIColor
|
||||
public var isVisible: Bool
|
||||
public var zIndex: Int32
|
||||
public var onTap: (() -> Void)?
|
||||
|
||||
public init(
|
||||
circleId: InlqCircleId,
|
||||
center: InlqLatLng,
|
||||
radiusMeters: Double,
|
||||
strokeColor: UIColor = UIColor(red: 0.13, green: 0.77, blue: 0.36, alpha: 1.0),
|
||||
strokeWidth: CGFloat = 4.0,
|
||||
fillColor: UIColor = UIColor(red: 0.13, green: 0.77, blue: 0.36, alpha: 0.2),
|
||||
isVisible: Bool = true,
|
||||
zIndex: Int32 = 0,
|
||||
onTap: (() -> Void)? = nil
|
||||
) {
|
||||
self.circleId = circleId
|
||||
self.center = center
|
||||
self.radiusMeters = radiusMeters
|
||||
self.strokeColor = strokeColor
|
||||
self.strokeWidth = strokeWidth
|
||||
self.fillColor = fillColor
|
||||
self.isVisible = isVisible
|
||||
self.zIndex = zIndex
|
||||
self.onTap = onTap
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
import Foundation
|
||||
import CoreLocation
|
||||
|
||||
/**
|
||||
* An immutable struct representing a pair of latitude and longitude coordinates.
|
||||
* Fully compatible with Google Maps iOS SDK and CoreLocation coordinate signatures.
|
||||
*/
|
||||
public struct InlqLatLng: Equatable, Hashable, Codable {
|
||||
public let latitude: Double
|
||||
public let longitude: Double
|
||||
|
||||
public init(latitude: Double, longitude: Double) {
|
||||
self.latitude = max(-90.0, min(90.0, latitude))
|
||||
self.longitude = max(-180.0, min(180.0, longitude))
|
||||
}
|
||||
|
||||
public init(coordinate: CLLocationCoordinate2D) {
|
||||
self.init(latitude: coordinate.latitude, longitude: coordinate.longitude)
|
||||
}
|
||||
|
||||
public var coordinate: CLLocationCoordinate2D {
|
||||
return CLLocationCoordinate2D(latitude: latitude, longitude: longitude)
|
||||
}
|
||||
|
||||
/// Calculates spherical distance in meters to another InlqLatLng
|
||||
public func distance(to other: InlqLatLng) -> Double {
|
||||
let loc1 = CLLocation(latitude: self.latitude, longitude: self.longitude)
|
||||
let loc2 = CLLocation(latitude: other.latitude, longitude: other.longitude)
|
||||
return loc1.distance(from: loc2)
|
||||
}
|
||||
|
||||
/// Calculates initial bearing in degrees to another InlqLatLng
|
||||
public func bearing(to other: InlqLatLng) -> Double {
|
||||
let lat1 = self.latitude * .pi / 180.0
|
||||
let lon1 = self.longitude * .pi / 180.0
|
||||
let lat2 = other.latitude * .pi / 180.0
|
||||
let lon2 = other.longitude * .pi / 180.0
|
||||
|
||||
let dLon = lon2 - lon1
|
||||
let y = sin(dLon) * cos(lat2)
|
||||
let x = cos(lat1) * sin(lat2) - sin(lat1) * cos(lat2) * cos(dLon)
|
||||
|
||||
let rad = atan2(y, x)
|
||||
return (rad * 180.0 / .pi + 360.0).truncatingRemainder(dividingBy: 360.0)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,76 @@
|
||||
import Foundation
|
||||
import UIKit
|
||||
|
||||
/**
|
||||
* Defines Marker options and overlays for iOS Native.
|
||||
* Fully compatible with Google Maps SDK (GMSMarker).
|
||||
*/
|
||||
public class InlqMarker {
|
||||
public var position: InlqLatLng
|
||||
public var title: String?
|
||||
public var snippet: String?
|
||||
public var icon: UIImage?
|
||||
public var isDraggable: Bool = false
|
||||
public var zIndex: Int32 = 0
|
||||
public var isVisible: Bool = true
|
||||
|
||||
public init(position: InlqLatLng, title: String? = nil, snippet: String? = nil) {
|
||||
self.position = position
|
||||
self.title = title
|
||||
self.snippet = snippet
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines Polyline path options for routes and paths on iOS.
|
||||
* Fully compatible with Google Maps SDK (GMSPolyline).
|
||||
*/
|
||||
public class InlqPolyline {
|
||||
public var points: [InlqLatLng]
|
||||
public var strokeColor: UIColor = UIColor(red: 0.0, green: 0.44, blue: 0.89, alpha: 1.0)
|
||||
public var strokeWidth: CGFloat = 4.0
|
||||
public var isGeodesic: Bool = true
|
||||
public var zIndex: Int32 = 0
|
||||
public var isVisible: Bool = true
|
||||
|
||||
public init(points: [InlqLatLng] = []) {
|
||||
self.points = points
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines Polygon options for military sectors and reachability polygons on iOS.
|
||||
* Fully compatible with Google Maps SDK (GMSPolygon).
|
||||
*/
|
||||
public class InlqPolygon {
|
||||
public var points: [InlqLatLng]
|
||||
public var holes: [[InlqLatLng]] = []
|
||||
public var strokeColor: UIColor = UIColor(red: 0.0, green: 0.44, blue: 0.89, alpha: 1.0)
|
||||
public var strokeWidth: CGFloat = 2.0
|
||||
public var fillColor: UIColor = UIColor(red: 0.0, green: 0.44, blue: 0.89, alpha: 0.2)
|
||||
public var zIndex: Int32 = 0
|
||||
public var isVisible: Bool = true
|
||||
|
||||
public init(points: [InlqLatLng] = []) {
|
||||
self.points = points
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Defines Circle options for accuracy zones and buffer areas on iOS.
|
||||
* Fully compatible with Google Maps SDK (GMSCircle).
|
||||
*/
|
||||
public class InlqCircle {
|
||||
public var center: InlqLatLng
|
||||
public var radiusMeters: Double
|
||||
public var strokeColor: UIColor = UIColor(red: 0.13, green: 0.77, blue: 0.36, alpha: 1.0)
|
||||
public var strokeWidth: CGFloat = 2.0
|
||||
public var fillColor: UIColor = UIColor(red: 0.13, green: 0.77, blue: 0.36, alpha: 0.2)
|
||||
public var zIndex: Int32 = 0
|
||||
public var isVisible: Bool = true
|
||||
|
||||
public init(center: InlqLatLng, radiusMeters: Double) {
|
||||
self.center = center
|
||||
self.radiusMeters = radiusMeters
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user