Skip to content

Commit 800a50e

Browse files
Search address data (#354)
* SearchResultMetadata.parkingType * Add region and country infos for the Search Address type * Get rid of BaseSearchAddress * Update public api * Bump version; Update changelog * Bump versions to beta.1
1 parent b86b436 commit 800a50e

File tree

58 files changed

+805
-355
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+805
-355
lines changed

CHANGELOG.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,18 @@
11
# Changelog for the Mapbox Search SDK for Android
22

3+
## 2.15.0-beta.1
4+
5+
### New features
6+
- Added new field `SearchResultMetadata.parkingType` - the type of parking at the POI.
7+
- Added new fields for the `SearchAddress` type - `regionInfo` and `countryInfo` which provide additional address information like region and country ISO codes.
8+
9+
### Mapbox dependencies
10+
- Search Native SDK `2.15.0-beta.1`
11+
- Common SDK `24.15.0-beta.1`
12+
- Maps SDK `11.15.0-beta.1`
13+
14+
15+
316
## 2.14.1
417

518
### Bug fixes

LICENSE.md

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,11 @@ License: [Android Software Development Kit License](https://developer.android.co
207207
===========================================================================
208208

209209
Mapbox Search Android uses portions of the Gson.
210+
License: [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0.txt)
211+
212+
===========================================================================
213+
214+
Mapbox Search Android uses portions of the error-prone annotations.
210215
License: [Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt)
211216

212217
===========================================================================
@@ -521,6 +526,11 @@ License: [Android Software Development Kit License](https://developer.android.co
521526
===========================================================================
522527

523528
Mapbox Search Android uses portions of the Gson.
529+
License: [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0.txt)
530+
531+
===========================================================================
532+
533+
Mapbox Search Android uses portions of the error-prone annotations.
524534
License: [Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt)
525535

526536
===========================================================================
@@ -847,6 +857,11 @@ License: [Android Software Development Kit License](https://developer.android.co
847857
===========================================================================
848858

849859
Mapbox Search Android uses portions of the Gson.
860+
License: [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0.txt)
861+
862+
===========================================================================
863+
864+
Mapbox Search Android uses portions of the error-prone annotations.
850865
License: [Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt)
851866

852867
===========================================================================
@@ -1279,6 +1294,11 @@ License: [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0.txt)
12791294

12801295
===========================================================================
12811296

1297+
Mapbox Search Android uses portions of the error-prone annotations.
1298+
License: [Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt)
1299+
1300+
===========================================================================
1301+
12821302
Mapbox Search Android uses portions of the Guava ListenableFuture only.
12831303
License: [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt)
12841304

@@ -1611,6 +1631,11 @@ License: [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0.txt)
16111631

16121632
===========================================================================
16131633

1634+
Mapbox Search Android uses portions of the error-prone annotations.
1635+
License: [Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt)
1636+
1637+
===========================================================================
1638+
16141639
Mapbox Search Android uses portions of the Guava ListenableFuture only.
16151640
License: [The Apache Software License, Version 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt)
16161641

@@ -1939,6 +1964,11 @@ License: [Android Software Development Kit License](https://developer.android.co
19391964
===========================================================================
19401965

19411966
Mapbox Search Android uses portions of the Gson.
1967+
License: [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0.txt)
1968+
1969+
===========================================================================
1970+
1971+
Mapbox Search Android uses portions of the error-prone annotations.
19421972
License: [Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt)
19431973

19441974
===========================================================================
@@ -2271,6 +2301,11 @@ License: [Android Software Development Kit License](https://developer.android.co
22712301
===========================================================================
22722302

22732303
Mapbox Search Android uses portions of the Gson.
2304+
License: [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0.txt)
2305+
2306+
===========================================================================
2307+
2308+
Mapbox Search Android uses portions of the error-prone annotations.
22742309
License: [Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt)
22752310

22762311
===========================================================================
@@ -2603,6 +2638,11 @@ License: [Android Software Development Kit License](https://developer.android.co
26032638
===========================================================================
26042639

26052640
Mapbox Search Android uses portions of the Gson.
2641+
License: [Apache-2.0](https://www.apache.org/licenses/LICENSE-2.0.txt)
2642+
2643+
===========================================================================
2644+
2645+
Mapbox Search Android uses portions of the error-prone annotations.
26062646
License: [Apache 2.0](http://www.apache.org/licenses/LICENSE-2.0.txt)
26072647

26082648
===========================================================================

MapboxSearch/autofill/api/autofill.api

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ public final class com/mapbox/search/autofill/AddressAutofillSuggestion$Creator
8080

8181
public final class com/mapbox/search/autofill/AddressComponents : android/os/Parcelable {
8282
public static final field CREATOR Landroid/os/Parcelable$Creator;
83-
public synthetic fun <init> (Lcom/mapbox/search/base/result/BaseSearchAddress;Lcom/mapbox/search/internal/bindgen/ResultMetadata;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
83+
public synthetic fun <init> (Lcom/mapbox/search/internal/bindgen/SearchAddress;Lcom/mapbox/search/internal/bindgen/ResultMetadata;Lkotlin/jvm/internal/DefaultConstructorMarker;)V
8484
public fun describeContents ()I
8585
public fun equals (Ljava/lang/Object;)Z
8686
public final fun getCountry ()Ljava/lang/String;

MapboxSearch/autofill/src/main/java/com/mapbox/search/autofill/AddressComponents.kt

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@ package com.mapbox.search.autofill
22

33
import android.os.Parcelable
44
import com.mapbox.search.base.core.CoreResultMetadata
5+
import com.mapbox.search.base.core.CoreSearchAddress
56
import com.mapbox.search.base.core.countryIso1
67
import com.mapbox.search.base.core.countryIso2
7-
import com.mapbox.search.base.result.BaseSearchAddress
88
import kotlinx.parcelize.Parcelize
99

1010
/**
1111
* Search result address. It's guaranteed that at least one address component is not empty.
1212
*/
1313
@Parcelize
1414
public class AddressComponents private constructor(
15-
private val coreSdkAddress: BaseSearchAddress,
15+
private val coreSdkAddress: CoreSearchAddress,
1616
private val coreMetadata: CoreResultMetadata?,
1717
) : Parcelable {
1818

@@ -66,13 +66,13 @@ public class AddressComponents private constructor(
6666
* Address region.
6767
*/
6868
public val region: String?
69-
get() = coreSdkAddress.region
69+
get() = coreSdkAddress.region?.name
7070

7171
/**
7272
* Address country.
7373
*/
7474
public val country: String?
75-
get() = coreSdkAddress.country
75+
get() = coreSdkAddress.country?.name
7676

7777
/**
7878
* The country code in ISO 3166-1.
@@ -148,15 +148,15 @@ public class AddressComponents private constructor(
148148

149149
@JvmSynthetic
150150
fun fromCoreSdkAddress(
151-
address: BaseSearchAddress?,
151+
address: CoreSearchAddress?,
152152
metadata: CoreResultMetadata?
153153
): AddressComponents? = if (address == null || address.isEmpty) {
154154
null
155155
} else {
156156
AddressComponents(address, metadata)
157157
}
158158

159-
private val BaseSearchAddress.isEmpty: Boolean
159+
private val CoreSearchAddress.isEmpty: Boolean
160160
get() {
161161
return listOf(
162162
houseNumber,
@@ -166,8 +166,8 @@ public class AddressComponents private constructor(
166166
postcode,
167167
place,
168168
district,
169-
region,
170-
country,
169+
region?.name,
170+
country?.name,
171171
).all { it.isNullOrEmpty() }
172172
}
173173
}

MapboxSearch/autofill/src/test/java/com/mapbox/search/autofill/AddressComponentsTest.kt

Lines changed: 26 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,15 @@
11
package com.mapbox.search.autofill
22

3+
import com.mapbox.search.base.core.CoreSearchAddress
34
import com.mapbox.search.base.core.countryIso1
45
import com.mapbox.search.base.core.countryIso2
56
import com.mapbox.search.base.core.createCoreResultMetadata
6-
import com.mapbox.search.base.result.BaseSearchAddress
77
import com.mapbox.search.common.tests.CommonSdkTypeObjectCreators
88
import com.mapbox.search.common.tests.ReflectionObjectsFactory
99
import com.mapbox.search.common.tests.ToStringVerifier
10+
import com.mapbox.search.common.tests.createCoreSearchAddress
11+
import com.mapbox.search.common.tests.createCoreSearchAddressCountry
12+
import com.mapbox.search.common.tests.createCoreSearchAddressRegion
1013
import com.mapbox.search.common.tests.withPrefabTestBoundingBox
1114
import com.mapbox.search.common.tests.withPrefabTestPoint
1215
import io.mockk.every
@@ -21,16 +24,16 @@ internal class AddressComponentsTest {
2124

2225
@Test
2326
fun `Check AddressComponents properties`() {
24-
val searchAddress = BaseSearchAddress(
27+
val searchAddress = createCoreSearchAddress(
2528
houseNumber = "5",
2629
street = "Rue De Marseille",
2730
neighborhood = "Porte-Saint-Martin",
2831
locality = "10th arrondissement of Paris",
2932
postcode = "75010",
3033
place = "Paris",
3134
district = "Paris district",
32-
region = "Paris region",
33-
country = "France"
35+
region = createCoreSearchAddressRegion("Paris region"),
36+
country = createCoreSearchAddressCountry("France"),
3437
)
3538

3639
val coreMetadata = createCoreResultMetadata(
@@ -48,26 +51,39 @@ internal class AddressComponentsTest {
4851
assertEquals(searchAddress.postcode, addressComponents.postcode)
4952
assertEquals(searchAddress.place, addressComponents.place)
5053
assertEquals(searchAddress.district, addressComponents.district)
51-
assertEquals(searchAddress.region, addressComponents.region)
52-
assertEquals(searchAddress.country, addressComponents.country)
54+
assertEquals(
55+
searchAddress.region,
56+
addressComponents.region?.let { createCoreSearchAddressRegion(it) },
57+
)
58+
assertEquals(
59+
searchAddress.country,
60+
addressComponents.country?.let {
61+
createCoreSearchAddressCountry(it)
62+
}
63+
)
5364
assertEquals(coreMetadata.countryIso1, addressComponents.countryIso1)
5465
assertEquals(coreMetadata.countryIso2, addressComponents.countryIso2)
5566
}
5667

5768
@Test
5869
fun `Check AddressComponents fromCoreSdkAddress() function`() {
59-
assertNotNull(AddressComponents.fromCoreSdkAddress(BaseSearchAddress(country = "France"), mockk()))
60-
assertNull(AddressComponents.fromCoreSdkAddress(BaseSearchAddress(), mockk()))
70+
assertNotNull(
71+
AddressComponents.fromCoreSdkAddress(
72+
createCoreSearchAddress(country = createCoreSearchAddressCountry("France")),
73+
mockk(),
74+
)
75+
)
76+
assertNull(AddressComponents.fromCoreSdkAddress(createCoreSearchAddress(), mockk()))
6177
}
6278

6379
@Test
6480
fun `Check AddressComponents formattedAddress() function`() {
6581
val formattedAddress = "Rue de Marseille, Paris, France"
6682

67-
val searchAddress = mockk<BaseSearchAddress>(relaxed = true)
83+
val searchAddress = mockk<CoreSearchAddress>(relaxed = true)
6884
every { searchAddress.street } returns "Rue de Marseille"
6985
every { searchAddress.place } returns "Paris"
70-
every { searchAddress.country } returns "France"
86+
every { searchAddress.country } returns createCoreSearchAddressCountry("France")
7187

7288
val addressComponents = requireNotNull(AddressComponents.fromCoreSdkAddress(searchAddress, mockk()))
7389

MapboxSearch/autofill/src/test/java/com/mapbox/search/autofill/TypeObjectCreator.kt

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,24 @@ package com.mapbox.search.autofill
22

33
import com.mapbox.geojson.Point
44
import com.mapbox.search.base.core.createCoreResultMetadata
5-
import com.mapbox.search.base.result.BaseSearchAddress
65
import com.mapbox.search.common.tests.CustomTypeObjectCreatorImpl
6+
import com.mapbox.search.common.tests.createCoreSearchAddress
7+
import com.mapbox.search.common.tests.createCoreSearchAddressCountry
8+
import com.mapbox.search.common.tests.createCoreSearchAddressRegion
79

810
internal object TypeObjectCreator {
911

1012
val SUGGESTION_CREATOR = CustomTypeObjectCreatorImpl(AddressAutofillSuggestion::class) { mode ->
11-
val searchAddress = BaseSearchAddress(
13+
val searchAddress = createCoreSearchAddress(
1214
houseNumber = "5",
1315
street = "Rue De Marseille",
1416
neighborhood = "Porte-Saint-Martin",
1517
locality = "10th arrondissement of Paris",
1618
postcode = "75010",
1719
place = "Paris",
1820
district = "Paris district",
19-
region = "Paris region",
20-
country = "France"
21+
region = createCoreSearchAddressRegion("Paris region"),
22+
country = createCoreSearchAddressCountry("France"),
2123
)
2224

2325
val coreMetadata = createCoreResultMetadata(
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package com.mapbox.search.base
2+
3+
import androidx.annotation.RestrictTo
4+
import com.mapbox.search.base.core.CoreSearchAddressCountry
5+
import com.mapbox.search.base.core.CoreSearchAddressRegion
6+
import com.mapbox.search.common.SearchAddressCountry
7+
import com.mapbox.search.common.SearchAddressRegion
8+
9+
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
10+
fun CoreSearchAddressCountry.mapToPlatform(): SearchAddressCountry? {
11+
return if (name.isEmpty() && countryCode.isNullOrEmpty() && countryCodeAlpha3.isNullOrEmpty()) {
12+
null
13+
} else {
14+
SearchAddressCountry(
15+
name = name,
16+
isoCodeAlpha2 = countryCode,
17+
isoCodeAlpha3 = countryCodeAlpha3,
18+
)
19+
}
20+
}
21+
22+
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
23+
fun SearchAddressCountry.mapToCore(): CoreSearchAddressCountry? {
24+
return CoreSearchAddressCountry(
25+
name = name,
26+
countryCode = isoCodeAlpha2,
27+
countryCodeAlpha3 = isoCodeAlpha3,
28+
)
29+
}
30+
31+
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
32+
fun CoreSearchAddressRegion.mapToPlatform(): SearchAddressRegion? {
33+
return if (name.isEmpty() && regionCode.isNullOrEmpty() && regionCodeFull.isNullOrEmpty()) {
34+
null
35+
} else {
36+
SearchAddressRegion(
37+
name = name,
38+
code = regionCode,
39+
codeFull = regionCodeFull,
40+
)
41+
}
42+
}
43+
44+
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP_PREFIX)
45+
fun SearchAddressRegion.mapToCore(): CoreSearchAddressRegion {
46+
return CoreSearchAddressRegion(
47+
name = name,
48+
regionCode = code,
49+
regionCodeFull = codeFull,
50+
)
51+
}

MapboxSearch/base/src/main/java/com/mapbox/search/base/core/CoreAliases.kt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ typealias CoreSearchResponse = com.mapbox.search.internal.bindgen.SearchResponse
1515
typealias CoreSearchResult = com.mapbox.search.internal.bindgen.SearchResult
1616
typealias CoreSuggestAction = com.mapbox.search.internal.bindgen.SuggestAction
1717
typealias CoreSearchAddress = com.mapbox.search.internal.bindgen.SearchAddress
18+
typealias CoreSearchAddressRegion = com.mapbox.search.internal.bindgen.SearchAddressRegion
19+
typealias CoreSearchAddressCountry = com.mapbox.search.internal.bindgen.SearchAddressCountry
1820
typealias CoreReverseMode = com.mapbox.search.internal.bindgen.ReverseMode
1921
typealias CoreReverseGeoOptions = com.mapbox.search.internal.bindgen.ReverseGeoOptions
2022
typealias CoreUserRecordsLayer = com.mapbox.search.internal.bindgen.UserRecordsLayer

MapboxSearch/base/src/main/java/com/mapbox/search/base/core/CoreFactoryFunctions.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ fun createCoreSearchOptions(
1717
navProfile: String? = null,
1818
etaType: String? = null,
1919
bbox: LonLatBBox? = null,
20+
// TODO support viewport
21+
viewport: LonLatBBox? = null,
2022
countries: List<String>? = null,
2123
fuzzyMatch: Boolean? = null,
2224
language: List<String>? = null,
@@ -39,6 +41,7 @@ fun createCoreSearchOptions(
3941
navProfile = navProfile,
4042
etaType = etaType,
4143
bbox = bbox,
44+
viewport = viewport,
4245
countries = countries,
4346
fuzzyMatch = fuzzyMatch,
4447
language = language,

MapboxSearch/base/src/main/java/com/mapbox/search/base/record/BaseIndexableRecord.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import android.os.Parcelable
44
import com.mapbox.geojson.Point
55
import com.mapbox.search.base.core.CoreResultMetadata
66
import com.mapbox.search.base.core.CoreRoutablePoint
7-
import com.mapbox.search.base.result.BaseSearchAddress
7+
import com.mapbox.search.base.core.CoreSearchAddress
88
import com.mapbox.search.base.result.BaseSearchResultType
99
import kotlinx.parcelize.Parcelize
1010

@@ -13,7 +13,7 @@ data class BaseIndexableRecord(
1313
val id: String,
1414
val name: String,
1515
val descriptionText: String?,
16-
val address: BaseSearchAddress?,
16+
val address: CoreSearchAddress?,
1717
val routablePoints: List<CoreRoutablePoint>?,
1818
val categories: List<String>?,
1919
val makiIcon: String?,

0 commit comments

Comments
 (0)