@mapsindoors/react-native-maps-indoors-mapbox 2.5.4 → 2.6.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (130) hide show
  1. package/README.md +3 -3
  2. package/android/build.gradle +1 -1
  3. package/package.json +1 -1
  4. package/react-native-maps-indoors-mapbox.podspec +2 -2
  5. package/android/src/main/java/com/mapsindoorsrn/core/DirectionsRendererModule.java +0 -322
  6. package/android/src/main/java/com/mapsindoorsrn/core/DirectionsServiceModule.java +0 -166
  7. package/android/src/main/java/com/mapsindoorsrn/core/MPDisplayRuleModule.java +0 -1699
  8. package/android/src/main/java/com/mapsindoorsrn/core/MapControlModule.java +0 -761
  9. package/android/src/main/java/com/mapsindoorsrn/core/MapsIndoorsModule.java +0 -410
  10. package/android/src/main/java/com/mapsindoorsrn/core/RCMapView.java +0 -16
  11. package/android/src/main/java/com/mapsindoorsrn/core/README.md +0 -3
  12. package/android/src/main/java/com/mapsindoorsrn/core/UtilsModule.java +0 -227
  13. package/android/src/main/java/com/mapsindoorsrn/core/models/BitmapStopIconConfig.java +0 -22
  14. package/android/src/main/java/com/mapsindoorsrn/core/models/Bounds.java +0 -19
  15. package/android/src/main/java/com/mapsindoorsrn/core/models/Filter.java +0 -77
  16. package/android/src/main/java/com/mapsindoorsrn/core/models/Location.java +0 -17
  17. package/android/src/main/java/com/mapsindoorsrn/core/models/MPCameraPosition.java +0 -34
  18. package/android/src/main/java/com/mapsindoorsrn/core/models/MPCameraUpdate.java +0 -68
  19. package/android/src/main/java/com/mapsindoorsrn/core/models/MPError.java +0 -38
  20. package/android/src/main/java/com/mapsindoorsrn/core/models/PositionProvider.java +0 -46
  21. package/android/src/main/java/com/mapsindoorsrn/core/models/PositionResult.java +0 -117
  22. package/android/src/main/java/com/mapsindoorsrn/core/models/Query.java +0 -30
  23. package/android/src/main/java/com/mapsindoorsrn/core/models/RouteStopIconConfigModel.java +0 -35
  24. package/ios/core/CameraPosition.swift +0 -15
  25. package/ios/core/CameraUpdate.swift +0 -19
  26. package/ios/core/CameraUpdateError.swift +0 -11
  27. package/ios/core/DirectionsRendererBridge.m +0 -59
  28. package/ios/core/DirectionsRendererModule.swift +0 -359
  29. package/ios/core/DirectionsServiceBridge.m +0 -55
  30. package/ios/core/DirectionsServiceModule.swift +0 -186
  31. package/ios/core/IconStopUrl.swift +0 -17
  32. package/ios/core/LabelGraphic.swift +0 -15
  33. package/ios/core/MPDisplayRuleBridge.m +0 -696
  34. package/ios/core/MPDisplayRuleModule.swift +0 -1704
  35. package/ios/core/MapControlBridge.m +0 -213
  36. package/ios/core/MapControlModule.swift +0 -702
  37. package/ios/core/MapsIndoorsBridge.m +0 -128
  38. package/ios/core/MapsIndoorsData.swift +0 -288
  39. package/ios/core/MapsIndoorsModule.swift +0 -363
  40. package/ios/core/RCMapView.swift +0 -16
  41. package/ios/core/README.md +0 -3
  42. package/ios/core/ReactPositionProvider.swift +0 -27
  43. package/ios/core/RouteIcon.swift +0 -34
  44. package/ios/core/UtilsBridge.m +0 -73
  45. package/ios/core/UtilsModule.swift +0 -182
  46. package/ios/core/helpers.swift +0 -57
  47. package/src/core/EventNames.ts +0 -21
  48. package/src/core/MPBadgePosition.ts +0 -12
  49. package/src/core/MPBounds.ts +0 -155
  50. package/src/core/MPBuilding.ts +0 -333
  51. package/src/core/MPBuildingCollection.ts +0 -57
  52. package/src/core/MPBuildingInfo.ts +0 -63
  53. package/src/core/MPCameraEvent.ts +0 -17
  54. package/src/core/MPCameraEventListener.ts +0 -17
  55. package/src/core/MPCameraPosition.ts +0 -82
  56. package/src/core/MPCameraUpdate.ts +0 -174
  57. package/src/core/MPCameraViewFitMode.ts +0 -25
  58. package/src/core/MPCategory.ts +0 -76
  59. package/src/core/MPCategoryCollection.ts +0 -62
  60. package/src/core/MPCollection.ts +0 -59
  61. package/src/core/MPCollisionHandling.ts +0 -12
  62. package/src/core/MPDataField.ts +0 -69
  63. package/src/core/MPDirectionsRenderer.ts +0 -238
  64. package/src/core/MPDirectionsService.ts +0 -152
  65. package/src/core/MPDisplayRule.ts +0 -1823
  66. package/src/core/MPEntity.ts +0 -60
  67. package/src/core/MPEntityInfo.ts +0 -28
  68. package/src/core/MPError.ts +0 -122
  69. package/src/core/MPFeatureTypes.ts +0 -8
  70. package/src/core/MPFilter.ts +0 -168
  71. package/src/core/MPFilterBehavior.ts +0 -115
  72. package/src/core/MPFloor.ts +0 -170
  73. package/src/core/MPFloorSelectorInterface.ts +0 -63
  74. package/src/core/MPGeometry.ts +0 -91
  75. package/src/core/MPHighlightBehavior.ts +0 -115
  76. package/src/core/MPHighway.ts +0 -14
  77. package/src/core/MPIconPlacement.ts +0 -13
  78. package/src/core/MPIconSize.ts +0 -39
  79. package/src/core/MPLabelGraphic.ts +0 -24
  80. package/src/core/MPLabelPosition.ts +0 -12
  81. package/src/core/MPLabelType.ts +0 -11
  82. package/src/core/MPLocation.ts +0 -410
  83. package/src/core/MPLocationPropertyNames.ts +0 -30
  84. package/src/core/MPLocationSettings.ts +0 -40
  85. package/src/core/MPLocationType.ts +0 -16
  86. package/src/core/MPMapConfig.ts +0 -280
  87. package/src/core/MPMapStyle.ts +0 -57
  88. package/src/core/MPMultiPolygon.ts +0 -218
  89. package/src/core/MPPOIType.ts +0 -43
  90. package/src/core/MPPoint.ts +0 -169
  91. package/src/core/MPPolygon.ts +0 -219
  92. package/src/core/MPPositionProviderInterface.ts +0 -45
  93. package/src/core/MPPositionResultInterface.ts +0 -42
  94. package/src/core/MPPropertyData.ts +0 -224
  95. package/src/core/MPQuery.ts +0 -69
  96. package/src/core/MPRoute.ts +0 -105
  97. package/src/core/MPRouteCoordinate.ts +0 -95
  98. package/src/core/MPRouteLeg.ts +0 -158
  99. package/src/core/MPRouteProperty.ts +0 -83
  100. package/src/core/MPRouteStep.ts +0 -186
  101. package/src/core/MPRouteStopIconConfig.ts +0 -82
  102. package/src/core/MPSelectionBehavior.ts +0 -114
  103. package/src/core/MPSelectionMode.ts +0 -4
  104. package/src/core/MPSettings3D.ts +0 -107
  105. package/src/core/MPSize.ts +0 -21
  106. package/src/core/MPSolution.ts +0 -189
  107. package/src/core/MPSolutionConfig.ts +0 -188
  108. package/src/core/MPSolutionDisplayRule.ts +0 -15
  109. package/src/core/MPUserRole.ts +0 -60
  110. package/src/core/MPUserRoleCollection.ts +0 -37
  111. package/src/core/MPUtils.ts +0 -178
  112. package/src/core/MPVenue.ts +0 -294
  113. package/src/core/MPVenueCollection.ts +0 -58
  114. package/src/core/MPVenueInfo.ts +0 -62
  115. package/src/core/MapControl.ts +0 -961
  116. package/src/core/MapView.tsx +0 -34
  117. package/src/core/MapsIndoors.ts +0 -571
  118. package/src/core/OnBuildingFoundAtCameraTargetListener.ts +0 -17
  119. package/src/core/OnFloorSelectionChangedListener.ts +0 -17
  120. package/src/core/OnFloorUpdateListener.ts +0 -16
  121. package/src/core/OnLegSelectedListener.ts +0 -17
  122. package/src/core/OnLiveLocationUpdateListener.ts +0 -17
  123. package/src/core/OnLocationSelectedListener.ts +0 -17
  124. package/src/core/OnMapClickListener.ts +0 -20
  125. package/src/core/OnMarkerClickListener.ts +0 -17
  126. package/src/core/OnMarkerInfoWindowClickListener.ts +0 -17
  127. package/src/core/OnPositionUpdateListener.ts +0 -17
  128. package/src/core/OnVenueFoundAtCameraTargetListener.ts +0 -17
  129. package/src/core/README.md +0 -3
  130. package/src/core/RouteStopIconConfig.ts +0 -10
@@ -1,182 +0,0 @@
1
- //
2
- // UtilsModule.swift
3
- // react-native-maps-indoors
4
- //
5
- // Created by Tim Mikkelsen on 26/04/2023.
6
- //
7
-
8
- import Foundation
9
- import MapsIndoors
10
- import MapsIndoorsCore
11
-
12
- @objc(UtilsModule)
13
- public class UtilsModule: NSObject {
14
-
15
- @objc public static func requiresMainQueueSetup() -> Bool {return false}
16
-
17
- @objc public func venueHasGraph(_ venueId: String, resolver resolve: @escaping RCTPromiseResolveBlock, rejecter reject: @escaping RCTPromiseRejectBlock) {
18
- Task {
19
- guard let venue = await MPMapsIndoors.shared.venueWith(id: venueId) else {
20
- return reject("Utils error", "Venue not found for current Solution", MPError.unknownError)
21
- }
22
-
23
- return resolve(venue.hasGraph)
24
- }
25
- }
26
-
27
- @objc public func pointAngleBetween(_ point1: String, point2: String, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
28
-
29
- guard let it = try? JSONDecoder().decode(MPPoint.self, from: Data(point1.utf8)) as MPPoint else {
30
- return reject("Utils error", "Venue not found for current Solution", MPError.unknownError)
31
- }
32
-
33
- guard let other = try? JSONDecoder().decode(MPPoint.self, from: Data(point2.utf8)) as MPPoint else {
34
- return reject("Utils error", "Venue not found for current Solution", MPError.unknownError)
35
- }
36
-
37
- return resolve(MPGeometryUtils.bearingBetweenPoints(from: it.coordinate, to: other.coordinate))
38
- }
39
-
40
- @objc public func pointDistanceTo(_ point1: String, point2: String, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
41
- guard let it = try? JSONDecoder().decode(MPPoint.self, from: Data(point1.utf8)) as MPPoint else {
42
- return reject("Utils error", "Venue not found for current Solution", MPError.unknownError)
43
- }
44
-
45
- guard let other = try? JSONDecoder().decode(MPPoint.self, from: Data(point2.utf8)) as MPPoint else {
46
- return reject("Utils error", "Venue not found for current Solution", MPError.unknownError)
47
- }
48
-
49
- return resolve(MPGeometryUtils.distance(from: MPGeoPoint(coordinate: it.coordinate), to: MPGeoPoint(coordinate: other.coordinate)))
50
- }
51
-
52
- @objc public func geometryIsInside(_ point: String, geometry: String, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
53
- guard let it = try? JSONDecoder().decode(MPPoint.self, from: Data(point.utf8)) as MPPoint else {
54
- return reject("Utils error", "Venue not found for current Solution", MPError.unknownError)
55
- }
56
-
57
- guard let geo = try? JSONDecoder().decode(MPGeometry.self, from: Data(geometry.utf8)) as MPGeometry else {
58
- return reject("Utils error", "Venue not found for current Solution", MPError.unknownError)
59
- }
60
-
61
- if (geo is MPPolygonGeometry) {
62
- let poly = geo.mp_polygon
63
- return resolve(poly?.containsCoordinate(it.coordinate))
64
- }else if (geo is MPMultiPolygonGeometry) {
65
- let multiPoly = geo.mp_multiPolygon
66
- resolve(multiPoly?.containsCoordinate(it.coordinate))
67
- }else {
68
- resolve(false)
69
- }
70
- }
71
-
72
- @objc public func geometryArea(_ geometry: String, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
73
-
74
- guard let geo = try? JSONDecoder().decode(MPGeometry.self, from: Data(geometry.utf8)) as MPGeometry else {
75
- return reject("Utils error", "Venue not found for current Solution", MPError.unknownError)
76
- }
77
-
78
- if (geo is MPPolygonGeometry) {
79
- let poly = geo.mp_polygon
80
- return resolve(poly?.area)
81
- }else if (geo is MPMultiPolygonGeometry) {
82
- let multiPoly = geo.mp_multiPolygon
83
- return resolve(multiPoly?.area)
84
- }else {
85
- return resolve(0)
86
- }
87
- }
88
-
89
- @objc public func polygonDistanceToClosestEdge(_ point: String, geometry: String, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
90
-
91
- guard let it = try? JSONDecoder().decode(MPPoint.self, from: Data(point.utf8)) as MPPoint else {
92
- return reject("Utils error", "Venue not found for current Solution", MPError.unknownError)
93
- }
94
-
95
- guard let geo = try? JSONDecoder().decode(MPGeometry.self, from: Data(geometry.utf8)) as MPGeometry else {
96
- return reject("Utils error", "Venue not found for current Solution", MPError.unknownError)
97
- }
98
-
99
- if(geo is MPPolygonGeometry){
100
-
101
- guard let outerRing = (geo.mp_polygon.coordinates.first?.map {CLLocationCoordinate2D(latitude: $0.latitude, longitude: $0.longitude)}) else {
102
- return reject("Utils error", "Venue not found for current Solution", MPError.unknownError)
103
- }
104
-
105
- var shortestDistance = Double.greatestFiniteMagnitude
106
- for i in 1 ..< outerRing.count {
107
- let p1 = outerRing[i-1]
108
- let p2 = outerRing[i]
109
-
110
- let distanceToLine = MPGeometryUtils.distancePointToLine(point: it.coordinate, lineStart: p1, lineEnd: p2)
111
- if( distanceToLine < shortestDistance) {
112
- shortestDistance = distanceToLine
113
- }
114
- }
115
-
116
- return resolve(shortestDistance)
117
- }
118
- return resolve(nil)
119
- }
120
-
121
- @objc public func parseMapClientUrl(_ venueId: String, locationId: String, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
122
- return resolve(MPMapsIndoors.shared.solution?.getMapClientUrlFor(venueId: venueId, locationId: locationId))
123
- }
124
-
125
- @objc public func setCollisionHandling(_ collisionHandling: NSNumber, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
126
- guard let collision = MPCollisionHandling.init(rawValue: collisionHandling.intValue) else {
127
- return reject("Utils error", "Venue not found for current Solution", MPError.unknownError)
128
- }
129
- MPMapsIndoors.shared.solution?.config.collisionHandling = collision
130
- return resolve(nil)
131
- }
132
-
133
- @objc public func enableClustering(_ enableClustering: Bool, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
134
- MPMapsIndoors.shared.solution?.config.enableClustering = enableClustering
135
- return resolve(nil)
136
- }
137
-
138
- @objc public func setExtrusionOpacity(_ opacity: Double, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
139
- MPMapsIndoors.shared.solution?.config.settings3D.extrusionOpacity = opacity
140
- return resolve(nil)
141
- }
142
-
143
- @objc public func setWallOpacity(_ opacity: Double, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
144
- MPMapsIndoors.shared.solution?.config.settings3D.wallOpacity = opacity
145
- return resolve(nil)
146
- }
147
-
148
- @objc public func setNewSelection(_ isNewSelection: Bool, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
149
- MPMapsIndoors.shared.solution?.config.newSelection = isNewSelection
150
- return resolve(nil)
151
- }
152
-
153
- @objc public func setSelectable(_ settingsId: String, value: Bool, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
154
- if (settingsId == "solution") {
155
- MPMapsIndoors.shared.solution?.config.locationSettings.selectable = value
156
- } else {
157
- if let location = MPMapsIndoors.shared.locationWith(locationId: settingsId) {
158
- if location.locationSettings == nil {
159
- location.locationSettings = MPLocationSettings()
160
- }
161
- location.locationSettings?.selectable = value
162
- } else {
163
- if let type = MPMapsIndoors.shared.solution?.types.first(where: {$0.name == settingsId}) {
164
- if type.locationSettings == nil {
165
- type.locationSettings = MPLocationSettings()
166
- }
167
- type.locationSettings?.selectable = value
168
- }
169
- }
170
- }
171
- return resolve(nil)
172
- }
173
-
174
- @objc public func setAutomatedZoomLimit(_ value: Double, resolver resolve: RCTPromiseResolveBlock, rejecter reject: RCTPromiseRejectBlock) {
175
- if value == -1 {
176
- MPMapsIndoors.shared.solution?.config.automatedZoomLimit = nil
177
- } else {
178
- MPMapsIndoors.shared.solution?.config.automatedZoomLimit = value
179
- }
180
- return resolve(nil)
181
- }
182
- }
@@ -1,57 +0,0 @@
1
- import MapsIndoors
2
-
3
- struct ErrorObject: Codable {
4
- var code: MPError
5
- var message: String
6
-
7
- public func asJSON() -> String {
8
- toJSON(self)
9
- }
10
- }; extension ErrorObject { // Don't want to lose default initializer, so this must be in an extension
11
- init(from mpError: MPError) {
12
- code = mpError
13
- message = String(describing: mpError)
14
- }
15
- }
16
-
17
- public func toJSON<T:Encodable>(_ object: T) -> String {
18
- let encoder = JSONEncoder()
19
- let jsonData = try! encoder.encode(object)
20
- let jsonStr = String(data: jsonData, encoding: .utf8)!
21
- return jsonStr
22
- }
23
-
24
- /// Provide 'type: YourType.self' if the type cannot be inferred from the type of the parameter or variable it will be used in
25
- public func fromJSON<T:Decodable>(_ jsonString: String, type _: T.Type = T.self) throws -> T {
26
- let decoder = JSONDecoder()
27
- let result = try decoder.decode(T.self, from: jsonString.data(using: .utf8)!)
28
- return result
29
- }
30
-
31
- private func fileToClassName(_ file: String) -> String {
32
- return file
33
- .split(separator: "/").last?
34
- .split(separator: ".").first
35
- .map{String($0)} ?? file
36
- }
37
-
38
- private func parsePrefix(file: String, func _func: String, line: Int, col: Int) -> String {
39
- let className = fileToClassName(file)
40
- let funcName: String = _func.split(separator: "(").first.map{String($0)} ?? _func
41
- return "\(className).\(funcName):\(line):\(col)"
42
- }
43
-
44
- public func doReject(_ reject: RCTPromiseRejectBlock, message: String,
45
- _file: String = #fileID, _func: String = #function, _line: Int = #line, _col: Int = #column) {
46
- let prefix = parsePrefix(file: _file, func: _func, line: _line, col: _col)
47
- let err = ErrorObject(code: .unknownError, message: "[\(prefix)] \(message)")
48
- return reject("NativeError", toJSON(err), err.code)
49
- }
50
-
51
- public func doReject(_ reject: RCTPromiseRejectBlock, error: Error,
52
- _file: String = #fileID, _func: String = #function, _line: Int = #line, _col: Int = #column) {
53
- let prefix = parsePrefix(file: _file, func: _func, line: _line, col: _col)
54
- let err = ErrorObject(code: .unknownError, message: "[\(prefix)] \(error)")
55
- return reject("NativeError", toJSON(err), error)
56
- }
57
-
@@ -1,21 +0,0 @@
1
- /**
2
- * A list of event aliases used internally by the MapsIndoors React Native Bindings to keep track of SDK events.
3
- *
4
- * @export
5
- * @enum {number}
6
- */
7
- export enum EventNames {
8
- cameraEvent = "cameraEvent",
9
- onFloorSelectionChanged = "onFloorSelectionChanged",
10
- onFloorUpdate = "onFloorUpdate",
11
- onLocationSelected = "onLocationSelected",
12
- onMapClick = "onMapClick",
13
- onPositionUpdate = "onPositionUpdate",
14
- onVenueFoundAtCameraTarget = "onVenueFoundAtCameraTarget",
15
- onBuildingFoundAtCameraTarget = "onBuildingFoundAtCameraTarget",
16
- onMarkerClick = "onMarkerClick",
17
- onInfoWindowClick = "onInfoWindowClick",
18
- onLiveLocationUpdate = "onLiveLocationUpdate",
19
- floorSelector = "floorSelector",
20
- onLegSelected = "onLegSelected",
21
- }
@@ -1,12 +0,0 @@
1
- /**
2
- * The possible position of the badge on an icon.
3
- *
4
- * @export
5
- * @enum {number}
6
- */
7
- export enum MPBadgePosition {
8
- bottomLeft,
9
- bottomRight,
10
- topLeft,
11
- topRight,
12
- }
@@ -1,155 +0,0 @@
1
- import MPPoint from "./MPPoint";
2
- import { Platform } from "react-native";
3
-
4
- /**
5
- * A simple representation of a bounding box.
6
- *
7
- * @export
8
- * @class MPBounds
9
- * @typedef {MPBounds}
10
- */
11
- export default class MPBounds {
12
- /**
13
- * Creates an instance of MPBounds.
14
- *
15
- * @constructor
16
- * @public
17
- * @param {MPPoint} northeast The northeastern most point.
18
- * @param {MPPoint} southwest The southwestern most point.
19
- */
20
- public constructor(
21
- public readonly northeast: MPPoint,
22
- public readonly southwest: MPPoint) {
23
- this.northeast = northeast;
24
- this.southwest = southwest;
25
- }
26
-
27
- /**
28
- * Creator for MPBounds, used to decode JSON from the MapsIndoors SDK.
29
- *
30
- * @public
31
- * @static
32
- * @param {MPBoundsParams} object
33
- * @returns {MPBounds}
34
- */
35
- public static create(object: MPBoundsParams): MPBounds {
36
- var bounds;
37
- if ((object as any).northeast.lat != null) {
38
- var northeast = new MPPoint((object as any).northeast.lat, (object as any).northeast.lng, (object as any).northeast.zLevel);
39
- var southwest = new MPPoint((object as any).southwest.lat, (object as any).southwest.lng, (object as any).southwest.zLevel);
40
- bounds = new MPBounds(northeast, southwest)
41
- }else {
42
- bounds = new MPBounds(
43
- object.northeast,
44
- object.southwest,
45
- );
46
- }
47
- return bounds
48
- }
49
-
50
- /**
51
- * Create a MPBounds from a Bounding Box.
52
- *
53
- * @public
54
- * @static
55
- * @param {number[]} bbox
56
- * @returns {MPBounds}
57
- */
58
- public static fromBBox(bbox: number[]): MPBounds {
59
- return new MPBounds(
60
- new MPPoint(bbox[3], bbox[2]),
61
- new MPPoint(bbox[1], bbox[0]),
62
- );
63
- }
64
-
65
- /**
66
- * The center of the bounds.
67
- *
68
- * @public
69
- * @readonly
70
- * @type {MPPoint}
71
- */
72
- public get center(): MPPoint {
73
- let latCenter = (this.northeast.latitude + this.southwest.latitude) / 2;
74
- let lngCenter = (this.northeast.longitude + this.southwest.longitude) / 2;
75
- return new MPPoint(latCenter, lngCenter);
76
- }
77
-
78
- /**
79
- * Check whether a point is containted within the bounds.
80
- *
81
- * @public
82
- * @param {MPPoint} point
83
- * @returns {boolean}
84
- */
85
- public contains(point: MPPoint): boolean {
86
- return ((point.latitude <= this.northeast.latitude &&
87
- point.latitude >= this.southwest.latitude)) &&
88
- ((point.longitude <= this.northeast.longitude &&
89
- point.longitude >= this.southwest.longitude));
90
- }
91
-
92
-
93
- public toJSON() {
94
- if(Platform.OS === 'ios') {
95
- return {
96
- "northeast": [this.northeast.longitude, this.northeast.latitude],
97
- "southwest": [this.southwest.longitude, this.southwest.latitude],
98
- }
99
- } else {
100
- return {
101
- "northeast": this.northeast,
102
- "southwest": this.southwest,
103
- }
104
- }
105
- }
106
-
107
- /**
108
- * Construct a bounds object from a collection of points, to ensure that the bounds contains all of them.
109
- *
110
- * @class
111
- */
112
- public static Builder = class {
113
- public north = Number.NEGATIVE_INFINITY;
114
- public south = Number.POSITIVE_INFINITY;
115
- public east = Number.NEGATIVE_INFINITY;
116
- public west = Number.POSITIVE_INFINITY;
117
-
118
- public include(point: MPPoint) {
119
- this.north = Math.max(this.north, point.latitude);
120
- this.south = Math.min(this.south, point.latitude);
121
- this.east = Math.max(this.east, point.longitude);
122
- this.west = Math.min(this.west, point.longitude);
123
- }
124
-
125
- public build(): MPBounds {
126
- if (this.north == Number.POSITIVE_INFINITY) {
127
- throw Error("Cannot build bounds with no coordinates");
128
- }
129
-
130
- return new MPBounds(new MPPoint(this.north, this.east), new MPPoint(this.south, this.west));
131
- }
132
- }
133
- }
134
-
135
- /**
136
- * Parameter interface for {@link MPBounds}.
137
- *
138
- * @export
139
- * @interface MPBoundsParams
140
- * @typedef {MPBoundsParams}
141
- */
142
- export interface MPBoundsParams {
143
- /**
144
- * A point.
145
- *
146
- * @type {MPPoint}
147
- */
148
- southwest: MPPoint;
149
- /**
150
- * A point.
151
- *
152
- * @type {MPPoint}
153
- */
154
- northeast: MPPoint;
155
- }