Skip to content

Commit

Permalink
update with version 0.13.0
Browse files Browse the repository at this point in the history
  • Loading branch information
GenChe committed Feb 27, 2024
1 parent 82a2cf9 commit 13ba708
Show file tree
Hide file tree
Showing 13 changed files with 175 additions and 106 deletions.
63 changes: 63 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,69 @@

---

## [0.13.0]

### Breaking changes

* Due to migration from MapLibre 5.13.0 to [6.1.1](https://github.com/maplibre/maplibre-native/releases/tag/ios-v6.0.0) additional changes needed:
* Changed the prefix of files, classes, methods, variables and everything from `MGL` to `MLN`. If you are using NSKeyedArchiver or similar mechanishm to save the state, the app may crash after this change when trying to unarchive the state using old names of the classes. You need to clean the saved state of the app and save it using new classes.
* The Swift package needs to be imported with `import MapLibre` instead of `import Mapbox`.
* removed support for iOS 11
* `VPSARKitLocationSource.State.limited(reason: VPSARKitLocationSource.State.Reason)` has been changed to `VPSARKitLocationSource.State.limited(reason: ARCamera.TrackingState.Reason)`:
* `VPSARKitLocationSource.State.Reason.correction` has been removed
* `WemapMapViewDelegate.map(_: MapView, didTouchFeature feature: MGLFeature)` and `WemapMapViewDelegate.map(_ map: MapView, didTouchPointOfInterest poi: PointOfInterest)` delegate methods have been removed.
Use `PointOfInterestManagerDelegate.pointOfInterestManager(_: PointOfInterestManager, didTouchPointOfInterest poi: PointOfInterest)` or `PointOfInterestManagerDelegate.pointOfInterestManager(_: PointOfInterestManager, didSelectPointOfInterest poi: PointOfInterest)` instead.
* `WemapMap.setEnvironment(_: Environment)` has been moved to `WemapCore.setEnvironment(_: Environment)`
* `Itinerary` has been changed:
* `let from: Coordinate` has been renamed to `let origin: Coordinate`
* `let to: Coordinate` has been renamed to `let destination: Coordinate`
* `let mode: TravelMode` has been renamed to `let transitMode: TravelMode`
* `Leg` has been changed:
* `let from: Coordinate` has been renamed to `let start: Coordinate`
* `let to: Coordinate` has been renamed to `let end: Coordinate`
* `let mode: TravelMode` has been renamed to `let transitMode: TravelMode`
* `TravelMode.bike` has been changed to `TravelMode.bike(preference: TravelMode.Preference)`
* `ItineraryParameters.init(from: Coordinate, to: Coordinate, mode: TravelMode, options: ItinerarySearchOptions)` has been changed to `ItineraryParameters.init(origin: Coordinate, destination: Coordinate, travelMode: TravelMode, searchOptions: ItinerarySearchOptions?)`
* `ItineraryParametersMultipleDestinations` has been renamed to `ItinerariesParametersMultipleDestinations`:
* `init(origin: Coordinate, pointsOfInterest: [PointOfInterest], mapId: Int, mode: TravelMode, options: ItinerarySearchOptions)` has been changed to `init(origin: Coordinate, pointsOfInterest: [PointOfInterest], mapId: Int, travelMode: TravelMode, searchOptions: ItinerarySearchOptions?)`
* `init(origin: Coordinate, coordinates: [Coordinate], mapId: Int?, mode: TravelMode, options: ItinerarySearchOptions)` has been changed to `init(origin: Coordinate, coordinates: [Coordinate], mapId: Int?, travelMode: TravelMode, searchOptions: ItinerarySearchOptions?)`
* `ItinerarySearchOptions` has been changed:
* `let useStairs: Bool` has been replaced by `let avoidStairs: Bool`
* `let useEscalators: Bool` has been replaced by `let avoidEscalators: Bool`
* `let useElevators: Bool` has been replaced by `let avoidElevators: Bool`
* `ItinerariesResponse` has been changed:
* `let from: Coordinate` has been removed
* `let to: Coordinate` has been removed
* `let error: String?` has been replaced by `let status: Status`
* `ItineraryManager` has been changed:
* `getItineraries(from: Coordinate, to: Coordinate, searchOptions: ItinerarySearchOptions)` has been changed to `getItineraries(origin: Coordinate, destination: Coordinate, travelMode: TravelMode, searchOptions: ItinerarySearchOptions?)`
* `NavigationManager` has been changed:
* `startNavigation(from: Coordinate, to: Coordinate, timeout: DispatchTimeInterval, options: NavigationOptions, itinerarySearchOptions: ItinerarySearchOptions)` has been changed to `startNavigation(origin: Coordinate?, destination: Coordinate, travelMode: TravelMode, options: NavigationOptions, searchOptions: ItinerarySearchOptions?, timeout: DispatchTimeInterval)`
* `startNavigation(_: Itinerary, options: NavigationOptions, itinerarySearchOptions: ItinerarySearchOptions)` has been changed to `startNavigation(_: Itinerary, options: NavigationOptions, searchOptions: ItinerarySearchOptions?)`

### Added

* CoreSDK: Add fastest, safest, tourism preferences for bike travel mode
* MapSDK: expose pitch from MapData, take into account the initial value
* MapSDK: expose bearing from MapData, take into account the initial value

### Changed

* CoreSDK: migrate to Itineraries API v2
* MapSDK: migrate to MapLibre 6.0.0
* MapSDK: replace didTouchFeature by didTouchPointOfInterest

### Fixed

* MapSDK: some POIs are selected and immediately unselected
* MapSDK: MapView is not deallocated on view dismissal

### Dependencies

* Itineraries API v1 -> v2
* MapLibre 5.13.0 -> 6.1.1
* NAOSwiftProvider 1.2.2 -> 1.3.0

## [0.12.0]

### Breaking changes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,12 @@ class CameraViewController: UIViewController {

vpsLocationSource.observer = self

weak var previousToast: UIView?
vpsLocationSource
.rx.didFail
.emit(onNext: { [unowned self] in
ToastHelper.showToast(message: "VPS failed with error - \($0)", onView: view)
previousToast?.removeFromSuperview()
previousToast = ToastHelper.showToast(message: "VPS failed with error - \($0)", onView: view)
})
.disposed(by: disposeBag)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import RxCocoa
import RxSwift
import UIKit
import WemapMapSDK
import WemapCoreSDK

class InitialViewController: UIViewController {

Expand All @@ -22,7 +23,8 @@ class InitialViewController: UIViewController {
super.viewDidLoad()

// uncomment if you want to use dev environment
// WemapMap.setEnvironment(.dev)
// WemapCore.setEnvironment(.dev)
// WemapCore.setItinerariesEnvironment(.dev)

let tap = UITapGestureRecognizer(target: self, action: #selector(dismissKeyboard))
view.addGestureRecognizer(tap)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//

import ARKit
import Mapbox
import MapLibre
import RxSwift
import UIKit
import WemapCoreSDK
Expand All @@ -27,9 +27,11 @@ final class NavigationViewController: MapViewController {
@IBOutlet var navigationInfo: UILabel!
@IBOutlet var userTrackingModeButton: UIButton!

private weak var currentVPSToast: UIView?

private weak var cameraVC: CameraViewController?

private var userCreatedAnnotations: [MGLAnnotation] {
private var userCreatedAnnotations: [MLNAnnotation] {
map.annotations?
.filter { $0.title == "user-created" } ?? []
}
Expand Down Expand Up @@ -82,7 +84,7 @@ final class NavigationViewController: MapViewController {
return
}
let coord = map.convert(gesture.location(in: map), toCoordinateFrom: map)
let point = MGLPointAnnotation()
let point = MLNPointAnnotation()
point.coordinate = coord
point.title = "user-created"
point.subtitle = "\(focusedBuilding?.activeLevel.id ?? 0.0)"
Expand Down Expand Up @@ -137,7 +139,7 @@ final class NavigationViewController: MapViewController {
var nextModeRaw = map.userTrackingMode.rawValue + 1
nextModeRaw = nextModeRaw < 3 ? nextModeRaw : 0

map.userTrackingMode = MGLUserTrackingMode(rawValue: nextModeRaw)!
map.userTrackingMode = MLNUserTrackingMode(rawValue: nextModeRaw)!

let title: String
switch map.userTrackingMode {
Expand All @@ -159,7 +161,7 @@ final class NavigationViewController: MapViewController {
disableStartButtons()

navigationManager
.startNavigation(from: origin, to: destination)
.startNavigation(origin: origin, destination: destination)
.subscribe(
onSuccess: { [unowned self] itinerary in
simulator?.setItinerary(itinerary)
Expand All @@ -185,7 +187,7 @@ final class NavigationViewController: MapViewController {
startNavigationFromUserCreatedAnnotationsButton.isEnabled = false
}

private func getLevelFromAnnotation(_ annotation: MGLAnnotation) -> [Float] {
private func getLevelFromAnnotation(_ annotation: MLNAnnotation) -> [Float] {
guard let building = focusedBuilding else {
debugPrint("Failed to retrieve focused building. Can't check if annotation is indoor or outdoor")
return []
Expand Down Expand Up @@ -256,9 +258,21 @@ extension NavigationViewController: VPSARKitLocationSourceDelegate {
func locationSource(_ locationSource: VPSARKitLocationSource, didChangeState state: VPSARKitLocationSource.State) {

debugPrint("state - \(state)")

guard state == .scanRequired, cameraVC == nil else { return }

showCamera(session: locationSource.session, assignCamera: true)

switch state {
case .scanRequired where cameraVC == nil:
showCamera(session: locationSource.session, assignCamera: true)
case let .limited(reason):
showVPSToast(message: "Tracking is limited due to - \(reason)")
case .noTracking:
showVPSToast(message: "Tracking is not available yet. Rotate your phone around")
default:
currentVPSToast?.removeFromSuperview()
}
}

private func showVPSToast(message: String) {
currentVPSToast?.removeFromSuperview()
currentVPSToast = ToastHelper.showToast(message: message, onView: view, hideDelay: .infinity)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import RxCocoa
import RxSwift
import UIKit
import WemapMapSDK
import WemapCoreSDK

class InitialViewController: UIViewController {

Expand All @@ -22,7 +23,8 @@ class InitialViewController: UIViewController {
super.viewDidLoad()

// uncomment if you want to use dev environment
// WemapMap.setEnvironment(.dev)
// WemapCore.setEnvironment(.dev)
// WemapCore.setItinerariesEnvironment(.dev)

let tap = UITapGestureRecognizer(target: self, action: #selector(dismissKeyboard))
view.addGestureRecognizer(tap)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
//
// swiftlint:disable force_try

import Mapbox
import MapLibre
import UIKit
import WemapCoreSDK
import WemapMapSDK
Expand Down
34 changes: 17 additions & 17 deletions Examples/Map/Sources/ViewControllers/NavigationViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © 2023 Wemap SAS. All rights reserved.
//

import Mapbox
import MapLibre
import RxSwift
import UIKit
import WemapCoreSDK
Expand All @@ -23,7 +23,7 @@ final class NavigationViewController: MapViewController {
@IBOutlet var removeUserCreatedAnnotationsButton: UIButton!
@IBOutlet var navigationInfo: UILabel!

private var userCreatedAnnotations: [MGLAnnotation] {
private var userCreatedAnnotations: [MLNAnnotation] {
map.annotations?
.filter { $0.title == "user-created" } ?? []
}
Expand Down Expand Up @@ -94,7 +94,7 @@ final class NavigationViewController: MapViewController {
return
}
let coord = map.convert(gesture.location(in: map), toCoordinateFrom: map)
let point = MGLPointAnnotation()
let point = MLNPointAnnotation()
point.coordinate = coord
point.title = "user-created"
point.subtitle = getCurrentLevel(for: coord)
Expand Down Expand Up @@ -143,29 +143,29 @@ final class NavigationViewController: MapViewController {

let origin, destination: Coordinate
if locationSourceType != .polestarEmulator {
origin = Coordinate(coordinate2D: from.coordinate, levels: fromLevels)
destination = Coordinate(coordinate2D: to.coordinate, levels: toLevels)
origin = .init(coordinate2D: from.coordinate, levels: fromLevels)
destination = .init(coordinate2D: to.coordinate, levels: toLevels)
} else {
// for testing you can comment out and uncomment placemarks in nao.kml file and corresponding origin/destination below
// Default path
// origin = Coordinate(coordinate2D: .init(latitude: 48.84487592, longitude: 2.37362684), level: -1)
// destination = Coordinate(coordinate2D: .init(latitude: 48.84428454, longitude: 2.37390447), level: 0)
// origin = .init(coordinate2D: .init(latitude: 48.84487592, longitude: 2.37362684), level: -1)
// destination = .init(coordinate2D: .init(latitude: 48.84428454, longitude: 2.37390447), level: 0)

// Path at less than 3 meters from network
origin = Coordinate(coordinate2D: .init(latitude: 48.84458308799957, longitude: 2.3731548097070134), level: 0)
destination = Coordinate(coordinate2D: .init(latitude: 48.84511200990592, longitude: 2.3738383127780676), level: 0)
origin = .init(coordinate2D: .init(latitude: 48.84458308799957, longitude: 2.3731548097070134), level: 0)
destination = .init(coordinate2D: .init(latitude: 48.84511200990592, longitude: 2.3738383127780676), level: 0)

// Path at less than 3 meters from network and route recalculation
// origin = Coordinate(coordinate2D: .init(latitude: 48.84458308799957, longitude: 2.3731548097070134), level: 0)
// destination = Coordinate(coordinate2D: .init(latitude: 48.84511200990592, longitude: 2.3738383127780676), level: 0)
// origin = .init(coordinate2D: .init(latitude: 48.84458308799957, longitude: 2.3731548097070134), level: 0)
// destination = .init(coordinate2D: .init(latitude: 48.84511200990592, longitude: 2.3738383127780676), level: 0)

// Path from level -1 to 0 and route recalculation
// origin = Coordinate(coordinate2D: .init(latitude: 48.84445563, longitude: 2.37319782), level: -1)
// destination = Coordinate(coordinate2D: .init(latitude: 48.84502948, longitude: 2.37451864), level: 0)
// origin = .init(coordinate2D: .init(latitude: 48.84445563, longitude: 2.37319782), level: -1)
// destination = .init(coordinate2D: .init(latitude: 48.84502948, longitude: 2.37451864), level: 0)

// Path indoor to outdoor
// origin = Coordinate(coordinate2D: .init(latitude: 48.84482873, longitude: 2.37378956), level: 0)
// destination = Coordinate(coordinate2D: .init(latitude: 48.8455159, longitude: 2.37305333))
// origin = .init(coordinate2D: .init(latitude: 48.84482873, longitude: 2.37378956), level: 0)
// destination = .init(coordinate2D: .init(latitude: 48.8455159, longitude: 2.37305333))
}

startNavigation(origin: origin, destination: destination)
Expand All @@ -180,7 +180,7 @@ final class NavigationViewController: MapViewController {
disableStartButtons()

navigationManager
.startNavigation(from: origin, to: destination, options: globalNavigationOptions /* , itinerarySearchOptions: .init(useStairs: false) */ )
.startNavigation(origin: origin, destination: destination, options: globalNavigationOptions/*, searchOptions: .init(avoidStairs: true)*/ )
.subscribe(
onSuccess: { [unowned self] itinerary in
simulator?.setItinerary(itinerary)
Expand Down Expand Up @@ -208,7 +208,7 @@ final class NavigationViewController: MapViewController {
startNavigationFromUserCreatedAnnotationsButton.isEnabled = false
}

private func getLevelFromAnnotation(_ annotation: MGLAnnotation) -> [Float] {
private func getLevelFromAnnotation(_ annotation: MLNAnnotation) -> [Float] {
guard let subtitle = annotation.subtitle! else {
return []
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
// Copyright © 2024 Wemap SAS. All rights reserved.
//

import UIKit
import RxCocoa
import RxSwift
import UIKit
import WemapCoreSDK
import WemapMapSDK

Expand All @@ -24,11 +24,9 @@ class POIsListViewController: UITableViewController {

private let disposeBag = DisposeBag()

private lazy var poisWithInfo: [PointOfInterestWithInfo] = {
mapView.pointOfInterestManager
.getPOIs()
.map { PointOfInterestWithInfo($0, ItineraryInfo.unknown()) }
}()
private lazy var poisWithInfo: [PointOfInterestWithInfo] = mapView.pointOfInterestManager
.getPOIs()
.map { PointOfInterestWithInfo($0, ItineraryInfo.unknown()) }

private var poiManager: PointOfInterestManager { mapView.pointOfInterestManager }

Expand All @@ -54,14 +52,13 @@ class POIsListViewController: UITableViewController {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell")!
cell.textLabel?.text = poi.name
cell.detailTextLabel?.text = "id - \(poi.id)\nlevel - \(poi.coordinate.levels.first ?? -1)\n" +
"address - \(poi.address)\ndistance - \(info.distance)\nduration - \(info.duration)"
"address - \(poi.address)\ndistance - \(info.distance)\nduration - \(info.duration)"
return cell

}
.disposed(by: disposeBag)
}

override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
override func tableView(_: UITableView, didSelectRowAt indexPath: IndexPath) {
mapView.pointOfInterestManager.selectPOI(poisWithInfo[indexPath.row].poi)
dismiss(animated: true)
}
Expand Down
Loading

0 comments on commit 13ba708

Please sign in to comment.