@@ -405,6 +405,7 @@ open class GeocodedPlacemark: Placemark {
405
405
406
406
private enum CodingKeys : String , CodingKey {
407
407
case routableLocations = " routable_points "
408
+ case relevance
408
409
}
409
410
410
411
private enum PointsCodingKeys : String , CodingKey {
@@ -421,8 +422,6 @@ open class GeocodedPlacemark: Placemark {
421
422
@objc open var routableLocations : [ CLLocation ] ?
422
423
423
424
public required init ( from decoder: Decoder ) throws {
424
- try super. init ( from: decoder)
425
-
426
425
let container = try decoder. container ( keyedBy: CodingKeys . self)
427
426
428
427
if let pointsContainer = try ? container. nestedContainer ( keyedBy: PointsCodingKeys . self, forKey: . routableLocations) ,
@@ -433,13 +432,17 @@ open class GeocodedPlacemark: Placemark {
433
432
routableLocations = [ CLLocation ( coordinate: coordinate) ]
434
433
}
435
434
}
435
+
436
+ relevance = try container. decodeIfPresent ( Double . self, forKey: . relevance) ?? - 1
437
+
438
+ try super. init ( from: decoder)
436
439
}
437
440
438
441
public override func encode( to encoder: Encoder ) throws {
439
- try super. encode ( to: encoder)
440
-
441
442
var container = encoder. container ( keyedBy: CodingKeys . self)
442
443
444
+ try container. encodeIfPresent ( relevance, forKey: . relevance)
445
+
443
446
if let routableLocations = routableLocations,
444
447
!routableLocations. isEmpty {
445
448
var pointsContainer = container. nestedContainer ( keyedBy: PointsCodingKeys . self, forKey: . routableLocations)
@@ -448,6 +451,8 @@ open class GeocodedPlacemark: Placemark {
448
451
routableLocations [ 0 ] . coordinate. latitude] )
449
452
try coordinatesContainer. encode ( routableLocation)
450
453
}
454
+
455
+ try super. encode ( to: encoder)
451
456
}
452
457
453
458
@objc open override var debugDescription : String {
@@ -486,6 +491,13 @@ open class GeocodedPlacemark: Placemark {
486
491
return properties? . maki
487
492
}
488
493
494
+ /**
495
+ A numerical score from 0 (least relevant) to 0.99 (most relevant) measuring
496
+ how well each returned feature matches the query. Use this property to
497
+ remove results that don’t fully match the query.
498
+ */
499
+ @objc open var relevance : Double
500
+
489
501
private var clippedAddressLines : [ String ] {
490
502
let lines = qualifiedNameComponents
491
503
if scope == . address {
0 commit comments