josephlacey / com.jlacey.electoral

GNU Affero General Public License v3.0
6 stars 12 forks source link

Adding cities, and looking up the District of Columbia as a City #26

Open joemcl opened 4 years ago

joemcl commented 4 years ago

@josephlacey thanks again so much. I've got the extension working after I figured out my error with help from @MegaphoneJon , see #25 . So, I want to help get Cities added in to the lookup, and not sure next steps to take for a PR to get Cities added to a lookup list, as one can do for Counties if a State is first selected in Administer -> System Settings -> Electoral API. My immediate goal is to add the District of Columbia as a City manually, and not sure what to enter. I've tried Dc, District_of _columbia, Washington_dc and none of those worked.

josephlacey commented 4 years ago

Hey @joemcl

It looks like Google codes it thus,

line1 | "1400 Constitution Avenue Northwest" city | "Washington" state | "DC" zip | "20560"

So the city is Washington, but you'll also want to include DC as a state. It's a unique case though. That will whitelist Washington as a city in other states as well. This seems like something that might be better written as an exception, or perhaps the settings interface could be rethought.

Here's how to view Google's output for a given address, which the extension is parsing. Note to replace $API_KEY with your Google API key.

https://www.googleapis.com/civicinfo/v2/representatives?key=$API_KEY&address=1400%20Constitution%20Ave%20NW,%20Washington,%20DC%2020560

Joseph

joemcl commented 4 years ago

Aha, thanks so much @josephlacey , tried that. So using State = District of Columbia (as in the dropdown) and City = Washington, I can now get districts for DC - but just the Country level lower chamber, and it shows as just us/district, since DC unfortunately doesn't have an actual member of congress, just a non-voting Delegate. Don't get any value back for City Council district, and of course DC does not have any counties.

josephlacey commented 4 years ago

I can now get districts for DC - but just the Country level lower chamber, and it shows as just us/district, since DC unfortunately doesn't have an actual member of congress, just a non-voting Delegate.

In the above test address, Google is showing Eleanor Holmes Norton as the rep, but I guess like the county since it's all one district the code might not process is correctly.

Don't get any value back for City Council district, and of course DC does not have any counties.

I'm also seeing city council reps and the mayor, but again the unique nature of the political lines may make it an exception to correct processing.

joemcl commented 4 years ago

Yeah DC has Wards for City Council which gets returned - but I think district is a unique Division type, it doesn't return state, and ward is a unique Division type, it doesn't return council_district, for DC, as for say, an address in New York City. Here's what gets returned for a street address in DC, Ward 5:

{
   "name": "D.C. City Council Member",
   "divisionId": "ocd-division/country:us/district:dc/ward:5",
   "officialIndices": [
    10
   ]
  }

and here's what gets returned for an address in NYC -

{
   "name": "New York City Council Member",
   "divisionId": "ocd-division/country:us/state:ny/place:new_york/council_district:7",
   "officialIndices": [
    14
   ]
  },
joemcl commented 4 years ago

And just out of curiosity, gonna see what gets returned for a Chicago address, Chicago has Wards for City Council as well:

{
   "name": "Chicago City Alderperson",
   "divisionId": "ocd-division/country:us/state:il/place:chicago/ward:47",
   "officialIndices": [
    13
   ]
  },

So yeah a Chicago address returns ward not council_district, like a DC address does.

joemcl commented 4 years ago

So rather than adding ward and district as new and distinct levels, seems like adding code to recognizeward as equivalent to council_district, and district as equivalent to state would then populate values for City Council districts/Wards for DC, Chicago, wherever else uses ward. And Puerto Rico has "municipios" which I think are equivalent to cities/places and will see what gets used for Puerto Rico, if it returns state or something else.