1 Answer
- Newest
- Most votes
- Most comments
0
Yes! Amazon Location Service can help with both of these requests. You can use the Geocode API to search for an Addresss, and the Reverse Geocode API to search for a coordinate. In both cases, you need to pass the Time Zone as an additional feature. Here is an example using the Geocode API and the AWS CLI:
aws geo-places geocode --query-text "1600 Pennsylvania Ave, Washington, DC" --additional-features "TimeZone" --intended-usage "Storage"
Which produces the following output:
{
"PricingBucket": "Stored",
"ResultItems": [
{
"PlaceId": "AQAAAGIAZ4ZMbDpXQkO3SUUnV4Q7_T3NhuQwwvfgSwZz8ggsWZGh9F2dUMvyPFiQqyb1GSNfL17ZiqrsC-jOePvISOXHIec5V2fRNOQDPhPwwW644FJWLaR3IezyJzVdS_qVKlTaWqJxzZhPwxNaFN8K6j3VQvIo1gu2SMDmsinhgJQlxACT1Q",
"PlaceType": "PointAddress",
"Title": "1600 Pennsylvania Ave SE, Washington, DC 20003-3228, United States",
"Address": {
"Label": "1600 Pennsylvania Ave SE, Washington, DC 20003-3228, United States",
"Country": {
"Code2": "US",
"Code3": "USA",
"Name": "United States"
},
"Region": {
"Code": "DC",
"Name": "District of Columbia"
},
"SubRegion": {
"Name": "District of Columbia"
},
"Locality": "Washington",
"District": "Hill East",
"PostalCode": "20003-3228",
"Street": "Pennsylvania Ave SE",
"StreetComponents": [
{
"BaseName": "Pennsylvania",
"Type": "Ave",
"TypePlacement": "AfterBaseName",
"TypeSeparator": " ",
"Suffix": "SE",
"Language": "en"
}
],
"AddressNumber": "1600"
},
"Position": [
-76.98198,
38.87908
],
"MapView": [
-76.98314,
38.87818,
-76.98082,
38.87998
],
"TimeZone": {
"Name": "America/New_York",
"Offset": "-04:00",
"OffsetSeconds": -14400
},
"MatchScores": {
"Overall": 0.99,
"Components": {
"Address": {
"Locality": 1.0,
"Intersection": [
0.94
],
"AddressNumber": 1.0
}
}
}
}
]
}
As you can see you get the Time Zone along with other information about the address. Note you will need the Intended Use option as you plan to persist in a database. This allows you to store the results of the query.
Now for reverse geocode, it's a similar story. Here's an example using AWS CLI:
aws geo-places reverse-geocode --query-position "[-94.71534726352156,39.297533082278115]" --additional-features "TimeZone" --intended-use "Storage"
Which produces the following output:
{
"PricingBucket": "Stored",
"ResultItems": [
{
"PlaceId": "AQAAAFIA7mDUGDbXf3SUNdF_Fsu9TsMbJ8mfHH_yz4CTCHCwGc5Xq7xqsaUkCk8LuS4_Urg7Fz20xIOJjmj18CimSuqkaxLDsPixe-8g47yJSMxKtKeI7uxPFeWH9JNRpQd3khgCKxjvBzpyHm-CgEQC-o09NnIh",
"PlaceType": "InterpolatedAddress",
"Title": "45 S International Sq, Kansas City, MO 64153-1106, United States",
"Address": {
"Label": "45 S International Sq, Kansas City, MO 64153-1106, United States",
"Country": {
"Code2": "US",
"Code3": "USA",
"Name": "United States"
},
"Region": {
"Code": "MO",
"Name": "Missouri"
},
"SubRegion": {
"Name": "Platte"
},
"Locality": "Kansas City",
"PostalCode": "64153-1106",
"Street": "S International Sq",
"StreetComponents": [
{
"BaseName": "International",
"Type": "Sq",
"TypePlacement": "AfterBaseName",
"TypeSeparator": " ",
"Prefix": "S",
"Language": "en"
}
],
"AddressNumber": "45"
},
"Position": [
-94.71536,
39.29757
],
"Distance": 5,
"MapView": [
-94.71649,
39.29757,
-94.71462,
39.29792
],
"TimeZone": {
"Name": "America/Chicago",
"Offset": "-05:00",
"OffsetSeconds": -18000
}
}
]
}
Relevant content
- asked 2 years ago
- AWS OFFICIALUpdated 5 months ago
- AWS OFFICIALUpdated 3 years ago