Google Maps API Geocode not returning results on passing postal code as a value to address param - google-maps

On trying to search a particular address by postal code(2000) it does not return the expected formatted address correctly, but whereas on searching using the address(frederiksberg) instead of postal code it returns the expected formatted address correctly.
https://maps.googleapis.com/maps/api/geocode/json?address=2000&components=country:Denmark&key=apikey
https://maps.googleapis.com/maps/api/geocode/json?address=frederiksberg&components=country:Denmark&key=apikey
But for a similar search with address set to postal code(4000) it returns the expected formatted address correctly, url below.
https://maps.googleapis.com/maps/api/geocode/json?address=4000&components=country:Denmark&key=apikey
Please let us know why its not returning the expected formatted address for address set to 2000.
TIA!

We experienced a similar issue with Postcode 2000 in Australia (which is Sydney), returned OK but with Zero_Result returned. All the other postcodes worked fine except 2000
Our initial search was
geocode({
address: "2000 Australia",
region: "AU" })
We solving it by adding "Postcode" before the search
geocode({
address: "Postcode 2000 Australia",
region: "AU" })

The Zip code 2000 matches more than one address. You can get the most common ones this way:
https://geocode.xyz/2000?region=DK
output:
Denmark x,y z: 55.68132,12.52966
🇩🇰
3 Solbjerg Plads, Frederiksberg C, Denmark » Confidence Score: 0.5
Frederiksberg DK 2000 Denmark
Frederiksberg Kommune DK 2000 Denmark
Brønshøj DK 2000 Denmark
Bronshoj DK 2000 Denmark
Frederiksberg C DK 2000 Denmark
Or in json format:
https://geocode.xyz/2000?region=DK&json=1
Json Output:
{
"standard": {
"addresst": "3 Solbjerg Plads",
"stnumber": "3",
"prov": "DK",
"city": "Frederiksberg C",
"countryname": "Denmark",
"postal": "2000",
"confidence": "0.5"
},
"longt": "12.52966",
"alt": {
"loc": [
{
"longt": "12.51635",
"city": "Frederiksberg",
"cc": "6353",
"latt": "55.68239"
},
{
"longt": "12.51704",
"city": "Frederiksberg Kommune",
"cc": "5629",
"latt": "55.68255"
},
{
"longt": "12.50332",
"city": "Bronshoj",
"cc": "2",
"latt": "55.67113"
},
{
"longt": "12.50332",
"city": "Bronshoj",
"cc": "2",
"latt": "55.67113"
},
{
"longt": "12.52966",
"city": "Frederiksberg C",
"cc": "1",
"latt": "55.68132"
}
]
},
"latt": "55.68132"
}

Related

How to sort a list of restaurant names by restaurant rating (possibly from Google Places or Yelp Fusion API)

I have a csv file with thousands of restaurant names and addresses that I need to sort by rating (data that is not in the csv). Is there a way to fill in the csv with this data? Possibly with Google Places API or Yelp Fusion API?
Both the Google Places API and Yelp Fusion API let you obtain a restaurant’s rating if you query with the business name and address. I’m going to explain how to do this but, first a caution about compliance. What you describe is clearly against the terms of service for both APIs. The only permitted use of their data is to display it on a publicly available website or app. Fetching and retaining it in a csv file is clearly improper. The APIs are intended for real-time query and immediate display of results for your users.
Google requires that the Places data be displayed in conjunction with a Google map or an approved "powered by Google" image. Additionally, no "pre-fetching, caching, or storage of content" is permitted. For details see https://developers.google.com/places/web-service/policies
Yelp requires attribution, basically requiring you to display the star rating and the Yelp logo with a link back to the business page on Yelp for the restaurant you have queried. See https://www.yelp.com/developers/display_requirements Furthermore, you can’t “cache, record, pre-fetch, or otherwise store any portion of the Yelp Content for a period longer than twenty-four (24) hours from receipt of the Yelp Content, or attempt or provide a means to execute any scraping or "bulk download" operations.” For full text and terms see https://www.yelp.com/developers/api_terms
With the legalese out of the way, here’s how to request a restaurant’s rating from Google Places:
https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=Applebees,234 W 42nd St,New York,NY&inputtype=textquery&fields=formatted_address,name,rating&key=YOUR_API_KEY
And, the JSON response:
{
"candidates": [
{
"formatted_address": "234 W 42nd St, New York, NY 10036, USA",
"name": "Applebee's Grill + Bar",
"rating": 3.6
}
],
"status": "OK"
}
Here is the same request for Yelp Fusion. There is no way to request just the rating. Results always contain everything in their database for the restaurant:
https://api.yelp.com/v3/businesses/search?term=applebees&location=234 W 42nd St,New York,NY&limit=1
JSON response:
{
"businesses": [
{
"id": "gytFjzBw-z5LZD-6JSMChg",
"alias": "applebees-grill-bar-new-york-3",
"name": "Applebee's Grill + Bar",
"image_url": "https://s3-media1.fl.yelpcdn.com/bphoto/CLizyj9S7pMvwGNm2dgdiQ/o.jpg",
"is_closed": false,
"url": "https://www.yelp.com/biz/applebees-grill-bar-new-york-3?adjust_creative=pnOv3Zj2REsNDMU4Z3-SLg&utm_campaign=yelp_api_v3&utm_medium=api_v3_business_search&utm_source=pnOv3Zj2REsNDMU4Z3-SLg",
"review_count": 444,
"categories": [
{
"alias": "tradamerican",
"title": "American (Traditional)"
},
{
"alias": "burgers",
"title": "Burgers"
},
{
"alias": "sportsbars",
"title": "Sports Bars"
}
],
"rating": 2,
"coordinates": {
"latitude": 40.756442,
"longitude": -73.988838
},
"transactions": [
"delivery",
"pickup"
],
"price": "$$",
"location": {
"address1": "234 W 42nd St",
"address2": "",
"address3": "",
"city": "New York",
"zip_code": "10036",
"country": "US",
"state": "NY",
"display_address": [
"234 W 42nd St",
"New York, NY 10036"
]
},
"phone": "+12123917414",
"display_phone": "(212) 391-7414",
"distance": 5.938732504864397
}
],
"total": 2900,
"region": {
"center": {
"longitude": -73.98880004882812,
"latitude": 40.75648701137637
}
}
}

NYC Open data DOB Missing Information

I am facing some issue in NYC department of building API.
help me if you know any other API giving the same information
I have used this API but didn't work for me
https://data.cityofnewyork.us/resource/83x8-shf7.json
Missing fields
permitee detailed address
https://data.cityofnewyork.us/resource/83x8-shf7.json?$where=filing_date BETWEEN '2018-05-01T06:00:00' AND '2018-05-30T10:00:00'
Also i am not able get expected data using filters for "filing_date" from same api
expected data should return all data between 2018-05-01 and 2018-05-30 for this API But i am getting only few results.
I am getting this data
[
{
"bin__": "3118313",
"bldg_type": "1",
"block": "05143",
"borough": "BROOKLYN",
"city": "BROOKLYN",
"community_board": "314",
"dobrundate": "2018-05-03T00:00:00.000",
"expiration_date": "2018-06-11T00:00:00.000",
"filing_date": "2018-05-02T00:00:00.000",
"filing_status": "INITIAL",
"gis_census_tract": "1522",
"gis_council_district": "40",
"gis_latitude": "40.641731",
"gis_longitude": "-73.966432",
"gis_nta_name": "Flatbush",
"house__": "328",
"issuance_date": "2018-05-02T00:00:00.000",
"job__": "321679046",
"job_doc___": "01",
"job_start_date": "2018-05-02T00:00:00.000",
"job_type": "A2",
"lot": "00068",
"non_profit": "N",
"owner_s_business_name": "N/A",
"owner_s_business_type": "INDIVIDUAL",
"owner_s_first_name": "MATTHEW",
"owner_s_house__": "328",
"owner_s_house_street_name": "ARGYLE ROAD",
"owner_s_last_name": "LIMA",
"owner_s_phone__": "3475968096",
"owner_s_zip_code": "11218",
"permit_sequence__": "01",
"permit_si_no": "3452932",
"permit_status": "ISSUED",
"permit_subtype": "OT",
"permit_type": "EW",
"permittee_s_business_name": "BMB BUILDER INC",
"permittee_s_first_name": "YUAN HANG",
"permittee_s_last_name": "XIAO",
"permittee_s_license__": "0612790",
"permittee_s_license_type": "GC",
"permittee_s_phone__": "9175776544",
"residential": "YES",
"self_cert": "N",
"site_fill": "NOT APPLICABLE",
"state": "NY",
"street_name": "ARGYLE ROAD",
"superintendent_business_name": "BMB BUILDER INC",
"superintendent_first___last_name": "YUAN HANG XIAO",
"work_type": "OT",
"zip_code": "11218"
}]
Expected Data should be
[{
"bin__": "1090379",
"bldg_type": "2",
"block": "00760",
"borough": "MANHATTAN",
"city": "GREAT NECK",
"community_board": "104",
"dobrundate": "2018-05-02T00:00:00.000",
"expiration_date": "2018-10-28T00:00:00.000",
"filing_date": "2018-05-01T00:00:00.000",
"filing_status": "RENEWAL",
"gis_census_tract": "111",
"gis_council_district": "3",
"gis_latitude": "40.753978",
"gis_longitude": "-73.993673",
"gis_nta_name": "Hudson Yards-Chelsea-Flatiron-Union Square",
"house__": "337",
"issuance_date": "2018-05-01T00:00:00.000",
"job__": "121187606",
"job_doc___": "01",
"job_start_date": "2016-02-19T00:00:00.000",
"job_type": "NB",
"lot": "00020",
"non_profit": "N",
"owner_s_business_name": "HKONY WEST 36 LLC",
"owner_s_business_type": "PARTNERSHIP",
"owner_s_first_name": "SAM",
"owner_s_house__": "420",
"owner_s_house_street_name": "GREAT NECK ROAD",
"owner_s_last_name": "CHANG",
"owner_s_phone__": "9178380886",
"owner_s_zip_code": "11021",
"permit_sequence__": "07",
"permit_si_no": "3451790",
"permit_status": "ISSUED",
"permit_type": "NB",
"permittee_s_business_name": "OMNIBUILD CONSTRUCTION IN",
"permittee_s_first_name": "PETER",
"permittee_s_last_name": "SERPICO",
"permittee_s_license__": "0608390",
"permittee_s_license_type": "GC",
"permittee_s_phone__": "2124191930",
"self_cert": "N",
"site_fill": "ON-SITE",
"site_safety_mgr_s_first_name": "ROBERT",
"site_safety_mgr_s_last_name": "FILIPPONE",
"special_district_1": "GC",
"state": "NY",
"street_name": "W 36 ST",
"zip_code": "10018"
}]
Combing through the JSON, it appears that these columns are not matching: permit_subtype, superintendent_business_name, superintendent_first___last_name, site_safety_mgr_s_first_name, site_safety_mgr_s_last_name, and special_district_1.
Looking at the original data sources, the columns that do not match are instances where the field is blank for that field. That is, bin__ = 1090379 does not have a permit_subtype, so it is omitted in the JSON (which is standard practice).
It will, however, be included in the CSV output since that format must include all columns: https://data.cityofnewyork.us/resource/83x8-shf7.csv?$where=filing_date%20BETWEEN%20%272018-05-01T06:00:00%27%20AND%20%272018-05-30T10:00:00%27.
This answer took a bit of digging because it wasn't immediately obvious which columns were different between the two examples. It's always helpful to over-explain to make it easier to track-down the issue.
Likewise, per the filing_date question, please include the query you're attempting to use.

Google Geocode format address contains hexadecimal characters

I am using google geocode API and for certain addresses I am seeing hexadecimal values in the formatted_address field.
Result from Google geocode API:
formatted_address" : "[Geocode \"8776\" (0xccbaa26b30dcc864), Feature (TYPE_ESTABLISHMENT_POI) \"Drum Oil & Propane Co\" [en LP] (0xfcffc173b794989a)
Can someone help me understand what could be the reason for the same.
This is a Google bug.
I tried the same with geocoder:
https://geocoder.ca/57ARMSTRONGRD+PLYMOUTH+MA+02360?geoit=xml
And got:
{
"standard": {
"staddress": "Armstrong Rd",
"stnumber": "57",
"prov": "MA",
"city": "Plymouth",
"postal": "02360-4806",
"confidence": "1"
},
"longt": "-70.695522",
"TimeZone": "America\/New_York",
"AreaCode": "508,774",
"latt": "41.956622"
}
<geodata>
<latt>41.956622</latt>
<longt>-70.695522</longt>
<AreaCode>508,774</AreaCode>
<TimeZone>America/New_York</TimeZone>
<standard>
<stnumber>57</stnumber>
<staddress>Armstrong Rd</staddress>
<city>Plymouth</city>
<prov>MA</prov>
<postal>02360-4806</postal>
<confidence>1</confidence>
</standard>
</geodata>
Here is the same result in json:
https://geocoder.ca/57ARMSTRONGRD+PLYMOUTH+MA+02360?geoit=xml&json=1
{
"standard": {
"staddress": "Armstrong Rd",
"stnumber": "57",
"prov": "MA",
"city": "Plymouth",
"postal": "02360-4806",
"confidence": "1"
},
"longt": "-70.695522",
"TimeZone": "America\/New_York",
"AreaCode": "508,774",
"latt": "41.956622"
}
:
https://geocoder.ca/57ARMSTRONGRD+PLYMOUTH+MA+02360

JSON String gets cutoff When emoji is in data [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
I have a VB.Net Webservice that returns data is a JSON string. Some of the data returned might have an EMOJI in it. When I return data that does not have an EMOJI in it the data come back fine.
Like this -
[
{
"ImgID": "150",
"ImgDesc": "Added to your portfolio",
"PublicID": "c0lbquvzitd3igohfh7x",
"ImgURL": "test.com",
"LikeCount": "0",
"CommentCnt": "2",
"PickCount": "",
"ServerUpdateDate": "1\/17\/2016 3:13:21 PM",
"UserName": "Deathstarspa",
"ProfileImgID": "hqhoiohfckzldgpdem6k",
"Location": "Chester County, PA, USA",
"dltflg": "False",
"PortName": "2 0 1 6 | M E N S",
"Categories": "Blowouts"
},
{
"ImgID": "151",
"ImgDesc": "Stone cold",
"PublicID": "udecff1bi0ymhewp1qlv",
"ImgURL": "Test.com",
"LikeCount": "0",
"CommentCnt": "0",
"PickCount": "",
"ServerUpdateDate": "1\/17\/2016 3:17:26 PM",
"UserName": "Deathstarspa",
"ProfileImgID": "hqhoiohfckzldgpdem6k",
"Location": "Chester County, PA, USA",
"dltflg": "False",
"PortName": "2 0 1 6 | M E N S",
"Categories": "Test"
}
]
If the data has an emoji anywhere in the sting the string gets cutoff at the very end.
It does not matter where the emoji is in the data.
Like -
[
{
"ImgID": "161",
"ImgDesc": "Bed ?????",
"PublicID": "gnw6ooo04ls21kqq8doo",
"ImgURL": "test.com",
"LikeCount": "0",
"CommentCnt": "0",
"PickCount": "",
"ServerUpdateDate": "2\/11\/2016 8:18:03 PM",
"UserName": "Deathstarspa",
"ProfileImgID": "hqhoiohfckzldgpdem6k",
"Location": "Chester County, PA, USA",
"dltflg": "False",
"PortName": "Bed Pics",
"Categories": "Blowouts,Treatments"
},
{
"ImgID": "162",
"ImgDesc": "Bed ?????",
"PublicID": "lrdxpvwxoq5zxpkagamo",
"ImgURL": "test.com",
"LikeCount": "0",
"CommentCnt": "0",
"PickCount": "",
"ServerUpdateDate": "2\/11\/2016 8:18:05 PM",
"UserName": "Deathstarspa",
"ProfileImgID": "hqhoiohfckzldgpdem6k",
"Location": "Chester County, PA, USA",
"dltflg": "False",
"PortName": "Test Pics"
Although you cannot see the Emojis in the ImgDesc piece the ????? represent the emoji. So the record with ImgID 161 is complete, but the record with ImgID of 162 get cutoff at "Test Pics,". If I remove the emoji from the ImgDesc then the data come back fine.
I am working with VB.NET and I have the Newtonsoft.Json dll referenced.
Is there something I need to do so the emojis do not cause issues?
You will need to properly encode the emoji, per the JSON standard. See the related answer below:
how can I Deserialize emoji in json in C#

Clarification required on Google Maps DistanceMatrixResponse

I am reading on Google Maps Distance Matrix Responses and am unable to understand how the response can have four distances when there are only two source-destination pairs. The following is from the documentation. I have use the API before but not this particular service. Please clarify. May be I am missing something basic here.
{
"origin_addresses": [ "Greenwich, Greater London, UK", "13 Great Carleton Square, Edinburgh, City of Edinburgh EH16 4, UK" ],
"destination_addresses": [ "Stockholm County, Sweden", "Dlouhá 609/2, 110 00 Praha-Staré Město, Česká republika" ],
"rows": [ {
"elements": [ {
"status": "OK",
"duration": {
"value": 70778,
"text": "19 hours 40 mins"
},
"distance": {
"value": 1887508,
"text": "1173 mi"
}
}, {
"status": "OK",
"duration": {
"value": 44476,
"text": "12 hours 21 mins"
},
"distance": {
"value": 1262780,
"text": "785 mi"
}
} ]
}, {
"elements": [ {
"status": "OK",
"duration": {
"value": 96000,
"text": "1 day 3 hours"
},
"distance": {
"value": 2566737,
"text": "1595 mi"
}
}, {
"status": "OK",
"duration": {
"value": 69698,
"text": "19 hours 22 mins"
},
"distance": {
"value": 1942009,
"text": "1207 mi"
}
} ]
} ]
The documentation states, and I quote:
The supported fields in a response are explained below.
originAddresses is an array containing the locations passed in the origins field of the Distance Matrix request. The addresses are returned as they are formatted by the geocoder.
destinationAddresses is an array containing the locations passed in the destinations field, in the format returned by the geocoder.
rows is an array of DistanceMatrixResponseRow objects, with each row corresponding to an origin.
elements are children of rows, and correspond to a pairing of the row's origin with each destination. They contain status, distance, and duration information for each origin/destination pair.
The distance, duration and duration_in_traffic fields for each element include both a value (which is always shown in meters or seconds), and a text field, which supplies a more human-readable version of the information. The distance's text value is formatted according to the unitSystem specified in the request (or in metric, if no preference was supplied).
The example you've given above shows two origins and two destinations, they are not paired. Each row response corresponds to an origin point, with each element being a route from that origin to a destination.
In the example above it is returning the distance from Greenwich to Stockholm County and the Czech Republic and then the distance from Edinburgh to Stockholm County and the Czech Republic. So the distances from point A to C and D, and then point B to C and D.
Does that clarify things a little?