Skip to content
This repository was archived by the owner on Jan 28, 2026. It is now read-only.

feature Us Census Bureau#118

Open
DR9885 wants to merge 7 commits into
chadly:masterfrom
InspereX:feature/UsCensusBureau
Open

feature Us Census Bureau#118
DR9885 wants to merge 7 commits into
chadly:masterfrom
InspereX:feature/UsCensusBureau

Conversation

@DR9885

@DR9885 DR9885 commented Dec 22, 2018

Copy link
Copy Markdown
Contributor

No description provided.

@DR9885 DR9885 requested a review from chadly January 28, 2020 00:32

@chadly chadly left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't had a chance to dig deep into this yet. But could you also update the README documentation to include this new geocoder, how it works, how to set it up. and any caveats?

@DR9885

DR9885 commented Feb 29, 2020

Copy link
Copy Markdown
Contributor Author

I haven't had a chance to dig deep into this yet. But could you also update the README documentation to include this new geocoder, how it works, how to set it up. and any caveats?

sure i'll get back to you when I do.

@DR9885

DR9885 commented Feb 29, 2020

Copy link
Copy Markdown
Contributor Author

@chadly done, added to readme

@DR9885 DR9885 requested a review from chadly March 5, 2020 20:37
@DR9885

DR9885 commented Mar 5, 2020

Copy link
Copy Markdown
Contributor Author

Also note, it doesnt support reverse geocoding & is US only... I added that to readme

@potatman

potatman commented Apr 4, 2020

Copy link
Copy Markdown

@chadly Any chance this could get merged? My company is using @DR9885's fork for our projects, but it would be nice to get back onto the main repo so we could pull from nuget rather than building the lib ourselves.

@seanat280 seanat280 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My team has been using this for a substantial period of time at this point with no issues. Can this get merged?

@DR9885

DR9885 commented Mar 29, 2021

Copy link
Copy Markdown
Contributor Author

@RodneyRichardson can you take a look?

@RodneyRichardson RodneyRichardson left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've not be able to test, but generally it looks like it might work, but there are a few improvements that could be made (such as not swallowing errors).

I don't have authority to approve merge requests.

private readonly string _format;
private readonly HttpClient _client;

public UsCensusBureauGeocoder(int benchmark = 4, string format = "json")

@RodneyRichardson RodneyRichardson Mar 30, 2021

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the magic number "4" (benchmark)? Can this be made into a (string) constant?

private readonly string _format;
private readonly HttpClient _client;

public UsCensusBureauGeocoder(int benchmark = 4, string format = "json")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the format parameter - the code only supports JSON, so hardcode it.

@@ -0,0 +1,98 @@
using System;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting in this file could be improved - Visual Studio autoformat should be sufficient.

/// </summary>
public class UsCensusBureauGeocoder : IGeocoder
{
private readonly int _benchmark;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

API defines benchmark as a string, and the example use, for example, "Public_AR_Census2020". Should this be a string? It might be worth referencing https://geocoding.geo.census.gov/geocoder/benchmarks for the list of available benchmarks.


var errors = json[UsCensusBureauConstants.ErrorsKey];
if (errors != null)
return new UsCensusBureauAddress[] {};

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't swallow errors. Create and throw a UsCensusBureauGeocodingException (wow, that's a long name - how about Ucb?) to wrap and expose the error.

/// - https://geocoding.geo.census.gov/
/// - https://geocoding.geo.census.gov/geocoder/Geocoding_Services_API.pdf
/// </summary>
public class UsCensusBureauGeocoder : IGeocoder

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider adding an IBatchGeocoder, as this looks to be supported by the API.

namespace Geocoding.Tests
{
[Collection("Settings")]
public class UsCensusBureauTest : GeocoderTest

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add tests for other "benchmark" values.

using Geocoding.UsCensusBureau;
using Xunit;

namespace Geocoding.Tests

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't skip tests. Assert that they behave as expected (such as throwing NotSupportedException, or returning/throwing an appropriate error).

sb.Append("street=").Append(WebUtility.UrlEncode(street))
.Append("&city=").Append(WebUtility.UrlEncode(city))
.Append("&state=").Append(WebUtility.UrlEncode(state))
.Append("&zip=").Append(WebUtility.UrlEncode(postalCode))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Does this work if any parameters are omitted? Perhaps add a test for partial address.

@chadly

chadly commented May 20, 2021

Copy link
Copy Markdown
Owner

I don't have authority to approve merge requests.

I'm obviously busy and neglecting things here. Do you want write access to the repo @RodneyRichardson. I would appreciate the help for this project.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants