Skip to content

Commit 7ec05ce

Browse files
committed
Restore provider compatibility surfaces
The remaining review feedback traced back to public compatibility breaks and stale repo wiring around legacy provider paths. This restores HERE legacy credential support, hardens provider request construction, preserves Google enum values, and realigns docs/tests/sample config with the supported compatibility surface.
1 parent 0cadcb3 commit 7ec05ce

13 files changed

Lines changed: 617 additions & 79 deletions

File tree

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ Includes a model and interface for communicating with current geocoding provider
77
| Google Maps | `Geocoding.Google` | Supported | API key or signed client credentials | `BusinessKey` supports signed Google Maps client-based requests when your deployment requires them. |
88
| Azure Maps | `Geocoding.Microsoft` | Supported | Azure Maps subscription key | Primary Microsoft-backed geocoder. |
99
| Bing Maps | `Geocoding.Microsoft` | Deprecated compatibility | Bing Maps enterprise key | `BingMapsGeocoder` remains available for existing consumers and is marked obsolete for new development. |
10-
| HERE Geocoding and Search | `Geocoding.Here` | Supported | HERE API key | Uses the current HERE Geocoding and Search API. |
10+
| HERE Geocoding and Search | `Geocoding.Here` | Supported | HERE API key or legacy app_id/app_code | Uses the current HERE Geocoding and Search API when an API key is configured and retains the legacy credential flow for compatibility. |
1111
| MapQuest | `Geocoding.MapQuest` | Supported | API key | Commercial API only. OpenStreetMap mode is no longer supported. |
1212
| Yahoo PlaceFinder/BOSS | `Geocoding.Yahoo` | Deprecated | OAuth consumer key + secret | Legacy package retained for compatibility, but the service remains deprecated and unverified. |
1313

@@ -76,7 +76,7 @@ Bing Maps requires an existing Bing Maps enterprise key. The provider is depreca
7676

7777
MapQuest requires a [developer API key](https://developer.mapquest.com/user/me/apps).
7878

79-
HERE requires a [HERE API key](https://www.here.com/docs/category/identity-and-access-management).
79+
HERE supports a [HERE API key](https://www.here.com/docs/category/identity-and-access-management) for the current Geocoding and Search API. Existing consumers can also continue using the legacy `app_id`/`app_code` constructor for compatibility.
8080

8181
Yahoo still uses the legacy OAuth consumer key and consumer secret flow, but onboarding remains unverified and the package is deprecated.
8282

@@ -93,7 +93,7 @@ Alternatively, if you are on Windows, you can open the solution in [Visual Studi
9393

9494
### Service Tests
9595

96-
You will need to generate API keys for each respective service to run the service tests. Make a `settings-override.json` as a copy of `settings.json` in the test project and put in your API keys. Then you should be able to run the tests.
96+
You will need credentials for each respective service to run the service tests. Make a `settings-override.json` as a copy of `settings.json` in the test project and put in your provider credentials there. For HERE, that can be either `Providers:Here:ApiKey` or the legacy `Providers:Here:AppId` plus `Providers:Here:AppCode` pair. Then you should be able to run the tests.
9797

9898
Most provider-backed integration tests skip with a message indicating which setting is required when credentials are missing. The Yahoo suite now follows the same credential gating, but the provider remains deprecated and unverified.
9999

@@ -105,4 +105,4 @@ The sample app in `samples/Example.Web` is an ASP.NET Core 10 minimal API that c
105105
dotnet run --project samples/Example.Web/Example.Web.csproj
106106
```
107107

108-
Configure a provider in `samples/Example.Web/appsettings.json` or via environment variables such as `Providers__Azure__ApiKey`, `Providers__Bing__ApiKey`, `Providers__Google__ApiKey`, `Providers__Here__ApiKey`, or `Providers__MapQuest__ApiKey`. Once the app is running, use `samples/Example.Web/sample.http` to call `/providers`, `/geocode`, and `/reverse`.
108+
Configure a provider in `samples/Example.Web/appsettings.json` or via environment variables such as `Providers__Azure__ApiKey`, `Providers__Bing__ApiKey`, `Providers__Google__ApiKey`, `Providers__Here__ApiKey`, `Providers__Here__AppId`, `Providers__Here__AppCode`, or `Providers__MapQuest__ApiKey`. Once the app is running, use `samples/Example.Web/sample.http` to call `/providers`, `/geocode`, and `/reverse`.

samples/Example.Web/Program.cs

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,8 @@ static string[] GetConfiguredProviders(ProviderOptions options)
117117

118118
configuredProviders.Add("google");
119119

120-
if (!String.IsNullOrWhiteSpace(options.Here.ApiKey))
120+
if (!String.IsNullOrWhiteSpace(options.Here.ApiKey)
121+
|| (!String.IsNullOrWhiteSpace(options.Here.AppId) && !String.IsNullOrWhiteSpace(options.Here.AppCode)))
121122
configuredProviders.Add("here");
122123

123124
if (!String.IsNullOrWhiteSpace(options.MapQuest.ApiKey))
@@ -162,23 +163,23 @@ static bool TryCreateGeocoder(string provider, ProviderOptions options, out IGeo
162163
return true;
163164

164165
case "here":
165-
if (!String.IsNullOrWhiteSpace(options.Here.AppId) || !String.IsNullOrWhiteSpace(options.Here.AppCode))
166+
if (!String.IsNullOrWhiteSpace(options.Here.ApiKey))
166167
{
167-
geocoder = default!;
168-
error = "HERE now uses Providers:Here:ApiKey. The legacy AppId/AppCode settings are no longer supported.";
169-
return false;
168+
geocoder = new HereGeocoder(options.Here.ApiKey);
169+
error = null;
170+
return true;
170171
}
171172

172-
if (String.IsNullOrWhiteSpace(options.Here.ApiKey))
173+
if (!String.IsNullOrWhiteSpace(options.Here.AppId) && !String.IsNullOrWhiteSpace(options.Here.AppCode))
173174
{
174-
geocoder = default!;
175-
error = "Configure Providers:Here:ApiKey before using the HERE provider.";
176-
return false;
175+
geocoder = new HereGeocoder(options.Here.AppId, options.Here.AppCode);
176+
error = null;
177+
return true;
177178
}
178179

179-
geocoder = new HereGeocoder(options.Here.ApiKey);
180-
error = null;
181-
return true;
180+
geocoder = default!;
181+
error = "Configure Providers:Here:ApiKey, or provide both Providers:Here:AppId and Providers:Here:AppCode, before using the HERE provider.";
182+
return false;
182183

183184
case "mapquest":
184185
if (String.IsNullOrWhiteSpace(options.MapQuest.ApiKey))
@@ -247,17 +248,17 @@ internal sealed class ProviderOptions
247248
public MapQuestProviderOptions MapQuest { get; init; } = new();
248249
}
249250

250-
internal sealed class GoogleProviderOptions
251+
internal sealed class AzureProviderOptions
251252
{
252253
public String ApiKey { get; init; } = String.Empty;
253254
}
254255

255-
internal sealed class AzureProviderOptions
256+
internal sealed class BingProviderOptions
256257
{
257258
public String ApiKey { get; init; } = String.Empty;
258259
}
259260

260-
internal sealed class BingProviderOptions
261+
internal sealed class GoogleProviderOptions
261262
{
262263
public String ApiKey { get; init; } = String.Empty;
263264
}

samples/Example.Web/appsettings.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@
1010
"ApiKey": ""
1111
},
1212
"Here": {
13+
"AppCode": "",
14+
"AppId": "",
1315
"ApiKey": ""
1416
},
1517
"MapQuest": {

src/Geocoding.Google/GoogleAddressType.cs

Lines changed: 43 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -9,89 +9,89 @@
99
public enum GoogleAddressType
1010
{
1111
/// <summary>The Unknown value.</summary>
12-
Unknown,
12+
Unknown = 0,
1313
/// <summary>The StreetAddress value.</summary>
14-
StreetAddress,
14+
StreetAddress = 1,
1515
/// <summary>The Route value.</summary>
16-
Route,
16+
Route = 2,
1717
/// <summary>The Intersection value.</summary>
18-
Intersection,
18+
Intersection = 3,
1919
/// <summary>The Political value.</summary>
20-
Political,
20+
Political = 4,
2121
/// <summary>The Country value.</summary>
22-
Country,
22+
Country = 5,
2323
/// <summary>The AdministrativeAreaLevel1 value.</summary>
24-
AdministrativeAreaLevel1,
24+
AdministrativeAreaLevel1 = 6,
2525
/// <summary>The AdministrativeAreaLevel2 value.</summary>
26-
AdministrativeAreaLevel2,
26+
AdministrativeAreaLevel2 = 7,
2727
/// <summary>The AdministrativeAreaLevel3 value.</summary>
28-
AdministrativeAreaLevel3,
28+
AdministrativeAreaLevel3 = 8,
2929
/// <summary>The AdministrativeAreaLevel4 value.</summary>
30-
AdministrativeAreaLevel4,
30+
AdministrativeAreaLevel4 = 32,
3131
/// <summary>The AdministrativeAreaLevel5 value.</summary>
32-
AdministrativeAreaLevel5,
32+
AdministrativeAreaLevel5 = 33,
3333
/// <summary>The AdministrativeAreaLevel6 value.</summary>
34-
AdministrativeAreaLevel6,
34+
AdministrativeAreaLevel6 = 34,
3535
/// <summary>The AdministrativeAreaLevel7 value.</summary>
36-
AdministrativeAreaLevel7,
36+
AdministrativeAreaLevel7 = 35,
3737
/// <summary>The ColloquialArea value.</summary>
38-
ColloquialArea,
38+
ColloquialArea = 9,
3939
/// <summary>The Locality value.</summary>
40-
Locality,
40+
Locality = 10,
4141
/// <summary>The SubLocality value.</summary>
42-
SubLocality,
42+
SubLocality = 11,
4343
/// <summary>The Neighborhood value.</summary>
44-
Neighborhood,
44+
Neighborhood = 12,
4545
/// <summary>The Premise value.</summary>
46-
Premise,
46+
Premise = 13,
4747
/// <summary>The Subpremise value.</summary>
48-
Subpremise,
48+
Subpremise = 14,
4949
/// <summary>The PostalCode value.</summary>
50-
PostalCode,
50+
PostalCode = 15,
5151
/// <summary>The NaturalFeature value.</summary>
52-
NaturalFeature,
52+
NaturalFeature = 16,
5353
/// <summary>The Airport value.</summary>
54-
Airport,
54+
Airport = 17,
5555
/// <summary>The Park value.</summary>
56-
Park,
56+
Park = 18,
5757
/// <summary>The PointOfInterest value.</summary>
58-
PointOfInterest,
58+
PointOfInterest = 19,
5959
/// <summary>The PostBox value.</summary>
60-
PostBox,
60+
PostBox = 20,
6161
/// <summary>The StreetNumber value.</summary>
62-
StreetNumber,
62+
StreetNumber = 21,
6363
/// <summary>The Floor value.</summary>
64-
Floor,
64+
Floor = 22,
6565
/// <summary>The Room value.</summary>
66-
Room,
66+
Room = 23,
6767
/// <summary>The PostalTown value.</summary>
68-
PostalTown,
68+
PostalTown = 24,
6969
/// <summary>The Establishment value.</summary>
70-
Establishment,
70+
Establishment = 25,
7171
/// <summary>The SubLocalityLevel1 value.</summary>
72-
SubLocalityLevel1,
72+
SubLocalityLevel1 = 26,
7373
/// <summary>The SubLocalityLevel2 value.</summary>
74-
SubLocalityLevel2,
74+
SubLocalityLevel2 = 27,
7575
/// <summary>The SubLocalityLevel3 value.</summary>
76-
SubLocalityLevel3,
76+
SubLocalityLevel3 = 28,
7777
/// <summary>The SubLocalityLevel4 value.</summary>
78-
SubLocalityLevel4,
78+
SubLocalityLevel4 = 29,
7979
/// <summary>The SubLocalityLevel5 value.</summary>
80-
SubLocalityLevel5,
80+
SubLocalityLevel5 = 30,
8181
/// <summary>The PostalCodeSuffix value.</summary>
82-
PostalCodeSuffix,
82+
PostalCodeSuffix = 31,
8383
/// <summary>The PostalCodePrefix value.</summary>
84-
PostalCodePrefix,
84+
PostalCodePrefix = 36,
8585
/// <summary>The PlusCode value.</summary>
86-
PlusCode,
86+
PlusCode = 37,
8787
/// <summary>The Landmark value.</summary>
88-
Landmark,
88+
Landmark = 38,
8989
/// <summary>The Parking value.</summary>
90-
Parking,
90+
Parking = 39,
9191
/// <summary>The BusStation value.</summary>
92-
BusStation,
92+
BusStation = 40,
9393
/// <summary>The TrainStation value.</summary>
94-
TrainStation,
94+
TrainStation = 41,
9595
/// <summary>The TransitStation value.</summary>
96-
TransitStation
96+
TransitStation = 42
9797
}

0 commit comments

Comments
 (0)