Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Does not accept state codes for US territories #82

Open
spakker opened this issue Nov 2, 2018 · 9 comments
Open

Does not accept state codes for US territories #82

spakker opened this issue Nov 2, 2018 · 9 comments
Assignees
Labels
Bug Hot High Priority Ticket
Milestone

Comments

@spakker
Copy link

spakker commented Nov 2, 2018

It doesn't accept us territory addresses. Please see the following examples below for more information.

ex 1: 2 John Brewers Bay, Charlotte Amalie West, St Thomas 00802, USVI
error: Invalid state code (too long): St Thomas (only accepts up to 3 char)
Comment: It also implies country code is allowed up to 2 char.

ex 2: West Santa Barbara Avenue, Dededo, Guam
error: cannot parse this address. state.location is None.

@fcopulgar
Copy link

fcopulgar commented Nov 30, 2018

This is the same problem in the issue #50, Does anyone know how to fix it?
The problem is in the _to_python function in models.py line 54, but I don't know how to fix it.

if country: if len(country_code) > Country._meta.get_field('code').max_length: if country_code != country: raise ValueError('Invalid country code (too long): %s'%country_code) country_code = '' country_obj = Country.objects.create(name=country, code=country_code) else: country_obj = None

@banagale
Copy link
Collaborator

Thank you for the report, @spakker and the note @fcopulgar.

As mentioned likely related to #50. Scheduled for an upcoming release.

@banagale banagale self-assigned this Jun 23, 2020
@banagale banagale added the Normal Medium Priority Ticket label Jun 23, 2020
@banagale banagale modified the milestones: Version 0.2.4, Version 0.2.5 Jun 28, 2020
@banagale
Copy link
Collaborator

banagale commented Aug 30, 2020

Json responses for example addresses:

John Brewers Bay, Charlotte Amalie West, St Thomas 00802, USVI

[{
	"address_components": [{
		"long_name": "Charlotte Amalie West",
		"short_name": "Charlotte Amalie West",
		"types": ["locality", "political"]
	}, {
		"long_name": "St. Thomas",
		"short_name": "St Thomas",
		"types": ["administrative_area_level_1", "political"]
	}, {
		"long_name": "U.S. Virgin Islands",
		"short_name": "VI",
		"types": ["country", "political"]
	}, {
		"long_name": "00802",
		"short_name": "00802",
		"types": ["postal_code"]
	}],
	"formatted_address": "Charlotte Amalie West, St Thomas 00802, USVI",
	"geometry": {
		"location": {
			"lat": 18.3435476,
			"lng": -64.9769925
		},
		"location_type": "GEOMETRIC_CENTER",
		"viewport": {
			"northeast": {
				"lat": 18.34489658029151,
				"lng": -64.97564351970848
			},
			"southwest": {
				"lat": 18.3421986197085,
				"lng": -64.9783414802915
			}
		}
	},
	"place_id": "ChIJudKjRwsbBYwRmb04mXKIhIo",
	"plus_code": {
		"compound_code": "82VF+C6 Charlotte Amalie West, St. Thomas, USVI",
		"global_code": "77CQ82VF+C6"
	},
	"types": ["establishment", "point_of_interest", "tourist_attraction"]
}]

West Santa Barbara Avenue, Dededo, Guam

[{
	"address_components": [{
		"long_name": "West Santa Barbara Avenue",
		"short_name": "West Santa Barbara Avenue",
		"types": ["route"]
	}, {
		"long_name": "Dededo",
		"short_name": "Dededo",
		"types": ["locality", "political"]
	}, {
		"long_name": "Guam",
		"short_name": "GU",
		"types": ["country", "political"]
	}],
	"formatted_address": "West Santa Barbara Avenue, Dededo, Guam",
	"geometry": {
		"bounds": {
			"northeast": {
				"lat": 13.5177564,
				"lng": 144.8473402
			},
			"southwest": {
				"lat": 13.5151533,
				"lng": 144.8439032
			}
		},
		"location": {
			"lat": 13.515887,
			"lng": 144.8460674
		},
		"location_type": "GEOMETRIC_CENTER",
		"viewport": {
			"northeast": {
				"lat": 13.5178038302915,
				"lng": 144.8473402
			},
			"southwest": {
				"lat": 13.5151058697085,
				"lng": 144.8439032
			}
		}
	},
	"place_id": "ChIJi_QHeA6DH2cRZ7XUNZLWC_I",
	"types": ["route"]
}, {
	"address_components": [{
		"long_name": "West Santa Barbara Avenue",
		"short_name": "West Santa Barbara Avenue",
		"types": ["route"]
	}, {
		"long_name": "Dededo",
		"short_name": "Dededo",
		"types": ["locality", "political"]
	}, {
		"long_name": "Guam",
		"short_name": "GU",
		"types": ["country", "political"]
	}],
	"formatted_address": "West Santa Barbara Avenue, Dededo, Guam",
	"geometry": {
		"bounds": {
			"northeast": {
				"lat": 13.5179939,
				"lng": 144.8442469
			},
			"southwest": {
				"lat": 13.5149883,
				"lng": 144.8339368
			}
		},
		"location": {
			"lat": 13.5165785,
			"lng": 144.8393999
		},
		"location_type": "GEOMETRIC_CENTER",
		"viewport": {
			"northeast": {
				"lat": 13.5179939,
				"lng": 144.8442469
			},
			"southwest": {
				"lat": 13.5149883,
				"lng": 144.8339368
			}
		}
	},
	"place_id": "ChIJ7ZzGmQWDH2cRimM1mnC1q4Y",
	"types": ["route"]
}]

@banagale
Copy link
Collaborator

Wettengel Rugby Field, Dededo, Guam

[{
	"address_components": [{
		"long_name": "Dededo",
		"short_name": "Dededo",
		"types": ["locality", "political"]
	}, {
		"long_name": "Guam",
		"short_name": "GU",
		"types": ["country", "political"]
	}],
	"formatted_address": "Dededo, Guam",
	"geometry": {
		"location": {
			"lat": 13.5248147,
			"lng": 144.832528
		},
		"location_type": "GEOMETRIC_CENTER",
		"viewport": {
			"northeast": {
				"lat": 13.5261636802915,
				"lng": 144.8338769802915
			},
			"southwest": {
				"lat": 13.5234657197085,
				"lng": 144.8311790197085
			}
		}
	},
	"place_id": "ChIJ9aKHUqqDH2cRpsikU9RmQFk",
	"plus_code": {
		"compound_code": "GRFM+W2 Dededo, Guam",
		"global_code": "7R56GRFM+W2"
	},
	"types": ["establishment", "point_of_interest", "stadium"]
}]

@banagale
Copy link
Collaborator

banagale commented Aug 30, 2020

Conflicting Addressing between Apple Maps and Google Maps.

Take Northern Region Community Health Center

Apple maps address:
520 W Santa Monica Ave
Dededo, Guam 96929
United States
Note, United States is included in address

Google maps address:
520 West Santa Monica Avenue Dededo, 96929
Note, Guam is not in the address, nor is United States. Google Maps actually defaults to showing a Google Plus Code, rather than a postal address.

In 2014, USPS had to send out 18,000 letters telling people Guam what their "correct mailing addresses" were!

In 2016, Amazon sellers forum members condemned a seller for not understanding how to handle shipping to Guam.

One user:

As indicated this is your fault because it is your responsibility to educate yourself regarding shipping matters.
For Guam and other Protectorates, you will not be able to print a label from Amazon but can do so with other services, or just purchase postage at the Post Office.
Format the address just as you would any domestic address
Name
PO or Street Address
City, Protectorate Zip
Do not put anything below that for country.
Generally speaking you should ship Priority Mail as other methods may be too slow.

US Naval base in Guam:
Apple maps address
W Marine Corps Dr
Santa Rita, Guam 96910
United States

Google Maps address:
Naval Magazine, 5, Santa Rita, Guam

Google geocode response:
'naval base guam'

[{
	"address_components": [{
		"long_name": "5",
		"short_name": "5",
		"types": ["route"]
	}, {
		"long_name": "Santa Rita",
		"short_name": "Santa Rita",
		"types": ["locality", "political"]
	}, {
		"long_name": "Guam",
		"short_name": "GU",
		"types": ["country", "political"]
	}],
	"formatted_address": "5, Santa Rita, Guam",
	"geometry": {
		"location": {
			"lat": 13.3876767,
			"lng": 144.6865487
		},
		"location_type": "GEOMETRIC_CENTER",
		"viewport": {
			"northeast": {
				"lat": 13.3890256802915,
				"lng": 144.6878976802915
			},
			"southwest": {
				"lat": 13.3863277197085,
				"lng": 144.6851997197085
			}
		}
	},
	"place_id": "ChIJv-nGg1BxH2cRtMJOo10aoKw",
	"plus_code": {
		"compound_code": "9MQP+3J Santa Rita, Guam",
		"global_code": "7R569MQP+3J"
	},
	"types": ["establishment", "point_of_interest"]
}]

@banagale
Copy link
Collaborator

banagale commented Aug 30, 2020

US Post office website, Post office location search:

Screen Shot 2020-08-30 at 10 31 39 AM

Notable that USPS does not acknowledge Guam as either a city or state in this form field. However, USPS requires Guam to be listed as a state in order to deliver mail there. Even they can't handle Guam consistently.

Putting in the zipcode: 96910
Screen Shot 2020-08-30 at 10 32 47 AM

So According to USPS's own website, they believe the proper formatting of a postal address for Guam is:

223 W CHALAN SANTO PAPA
HAGATNA, GU 96910-9998

This is a trip, apparently different shipping providers have different requirements for how to address packages destined for US territories:

From ShipStation.com help:

USPS, UPS, DHL, and FedEx require packages going to US territories (like Puerto Rico) to follow certain address formats in order to get rates or create shipping labels. In some cases, you'll need to fill out customs declarations, even though the carrier considers the shipment to be domestic.

Typically, USPS providers will require the country to be listed as the United States, while UPS and FedEx will require the country to be the territory name that is input as the state. See the below sections for details by carrier.

@banagale
Copy link
Collaborator

Oh boy, so some conclusions on this rabbit hole of US Territories.

It appears django-address needs to take a position on what the correct addressing of a US Territory is. The reason for this is that google maps geocoder does not provide typical locality / state / administrative level 1 description for Guam.

If you look at the naval base guam geocode response example above, Google describes Guam as a country. Well, that is not the position of the United States. The US thinks guam is a territory or protectorate. So if you're in the united states and are sending mail to guam, you address things to guam as:

Street number, route,
city name, GU zip code

It appears it is okay to say the country is the United States beneath it.

However if you were to spell out Guam, it is possible a USPS worker will mistake it as an international post and it will dissapear.

@banagale
Copy link
Collaborator

This will need some special work, but here's a proposed path forward:

  1. Commit to the idea that for the purposes of postal addresses, US territories like Puerto Rico, Guam or the Virgin Islands--they are not countries.

Guam has sought to be an independent state and just a few weeks ago was inducted into the UNPO or Underrepresented Nations and People's Organization. Each territory has its own history and current status of desire for independence.

I think it is important in creating software that describes these places that we take decolonization into account. And to some extent writing code that recategorizes Google's output of Guam as a country into the State field sort of perpetuates and strengthens the existing political status of Guam.

However! If you are building an ecommerce site and you want to be able to sell to guam, you still need to save people's addresses and ideally you want stuff you send to actually reach one of the the 168,000 people living in Guam. So to some extent, not writing software that allows major postal carriers to deliver mail also leaves these people out in a very material way.

So, perhaps the best thing we could do is to provide some level of education about these people's views towards independent governance while also writing code that allows them to receive packages via "correctly" formatted addresses.

  1. Decide to either write custom handling for US territories where the AddressField validator processes Country into state and the short code into state, giving the country as United Sates.

:P

I think that's it.

This is not the same problem as #50, which is actually a trivial problem compared to this, as it does not involve considering a people's right to self governance or the history of and present status of colonization by the United States.

Next Steps:

  1. Identify each US territory and gather clarifying responses from google geocoder on each to confirm mapping of country field to state code will result in "correct" addresses.
  2. Customize address.widgest.AddressWidget and any other code that provides special consideration of these territories.

@banagale banagale modified the milestones: Version 0.2.5, Version 0.2.6 Aug 30, 2020
@banagale
Copy link
Collaborator

Thanks to @carlosa54 from Puerto Rico for providing some feedback on this

To summarize, their feedback is to go ahead with plans to treat PR as a state and that this is well-normalized in software interfaces at the moment.

They specifically point out that Amazon does allow you to put Puerto Rico in as a country if you want.

Here's another take at to-do's on this:

 - Identify each US territory and gather clarifying responses from google geocoder on each to confirm mapping of country field to state code will result in "correct" addresses.

 - Write tests for country codes for each territory, 

 - Customize address.widgest.AddressWidget and any other code that provides special consideration of these territories.

@banagale banagale added Hot High Priority Ticket and removed Normal Medium Priority Ticket labels Sep 13, 2020
@banagale banagale modified the milestones: Version 0.2.6, Version 0.2.7 May 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Hot High Priority Ticket
Projects
None yet
Development

No branches or pull requests

3 participants