Can someone test this code and give me the result please?

I’m making an app in which I need to display the society/apartment complex/housing community name of the user, by using the location sensor. The app is working for me in India, and displays my society name, but I needed to know whether it works for other people too, in different countries.
Could someone please create an app with this


code and tell me whether it displays the name of your society?

Thanks!

cc: @muneer @catsarisky @domhnallohanlon @tatiang (really sorry for 'cc’ing you, but I know all of you are in different countries.)

Edit: I forgot to include why I need testers exactly. Geoapify had a list of 4 different addresses in its response. The only one (at least for me) which had the society name was the 2nd item on the list. I’m not sure it gives the same 4-item-list response for everyone though, and I’m not sure if the Society name is in the 2nd item for everyone, so I needed testers from different parts of the world.

2 Likes

Will do later and update you.

1 Like

Great, thank you so much!

1 Like

This is the output

{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"datasource":{"sourcename":"openstreetmap","attribution":"© OpenStreetMap contributors","license":"Open Database Licence","url":"https://www.openstreetmap.org/copyright"},"name":"Road 835","street":"Road 835","suburb":"Mina Salman","city":"Manama","state":"Capital Governorate","postcode":"604","country":"Bahrain","country_code":"bh","lon":50.6177152,"lat":26.1560623,"formatted":"Road 835, Manama 604, Bahrain","address_line1":"Road 835","address_line2":"Manama 604, Bahrain","distance":28.25210176566213,"rank":{"importance":0.09999999999999998},"place_id":"51fd1eab4a114f49405977a3eab2f3273a40f00102f901d3cb871a00000000920308526f616420383335"},"geometry":{"type":"Point","coordinates":[50.6177152,26.1560623]},"bbox":[50.6166047,26.1556595,50.6191084,26.1563611]},{"type":"Feature","geometry":{"type":"Point","coordinates":[50.618197,26.157144]},"properties":{"name":"Road 849","street":"Road 849","distance":102.87275136843546,"country":"Bahrain","datasource":{"sourcename":"openstreetmap","attribution":"© OpenStreetMap contributors","license":"Open Database Licence","url":"https://www.openstreetmap.org/copyright"},"country_code":"bh","state":"Capital","lon":50.618197,"lat":26.157144,"result_type":"street","formatted":"Road 849, Bahrain","address_line1":"Road 849","address_line2":"Bahrain","rank":{"popularity":1.9405135342542503},"place_id":"511fbe4c14214f4940593bc3d4963a283a40f00103f901788e1b0100000000920308526f616420383439"},"bbox":[50.617942,26.1571,50.618453,26.157188]},{"type":"Feature","geometry":{"type":"Point","coordinates":[50.61666,26.156361]},"properties":{"name":"Road 834","street":"Road 834","distance":123.57480628018168,"country":"Bahrain","datasource":{"sourcename":"openstreetmap","attribution":"© OpenStreetMap contributors","license":"Open Database Licence","url":"https://www.openstreetmap.org/copyright"},"country_code":"bh","state":"Capital","lon":50.61666,"lat":26.156361,"result_type":"street","formatted":"Road 834, Bahrain","address_line1":"Road 834","address_line2":"Bahrain","rank":{"popularity":1.9405618540059437},"place_id":"512d6002b7ee4e494059af5e454607283a40f00103f901c8881b0100000000920308526f616420383334"},"bbox":[50.616542,26.155914,50.617271,26.156904]},{"type":"Feature","geometry":{"type":"Point","coordinates":[50.618983,26.155184]},"properties":{"name":"Bahrain Primary Girls School","distance":161.7118179457067,"country":"Bahrain","datasource":{"sourcename":"openstreetmap","attribution":"© OpenStreetMap contributors","license":"Open Database Licence","url":"https://www.openstreetmap.org/copyright"},"street":"Bahrain Primary Girls School","country_code":"bh","state":"Capital","lon":50.618983,"lat":26.155184,"result_type":"amenity","formatted":"Bahrain Primary Girls School, Bahrain","address_line1":"Bahrain Primary Girls School","address_line2":"Bahrain","rank":{"popularity":1.7654562591455374},"place_id":"51d6e3bed53a4f494059cadc7c23ba273a40f00102f901e2826f130000000092031c4261687261696e205072696d617279204769726c73205363686f6f6c"},"bbox":[50.6178013,26.1540375,50.6200544,26.1561687]},{"type":"Feature","geometry":{"type":"Point","coordinates":[50.619365,26.156935]},"properties":{"name":"Sitra Heath Centre","distance":164.9792930832735,"country":"Bahrain","datasource":{"sourcename":"openstreetmap","attribution":"© OpenStreetMap contributors","license":"Open Database Licence","url":"https://www.openstreetmap.org/copyright"},"street":"Sitra Heath Centre","country_code":"bh","state":"Capital","lon":50.619365,"lat":26.156935,"result_type":"amenity","formatted":"Sitra Heath Centre, Bahrain","address_line1":"Sitra Heath Centre","address_line2":"Bahrain","rank":{"popularity":1.9405135342542503},"place_id":"51bea4315a474f494059079964e42c283a40f00102f90106ca171d0000000092031253697472612048656174682043656e747265"},"bbox":[50.6191932,26.1567548,50.6195331,26.1571918]},{"type":"Feature","geometry":{"type":"Point","coordinates":[50.616502,26.157757]},"properties":{"name":"Road 832","street":"Road 832","distance":216.7556431859009,"country":"Bahrain","datasource":{"sourcename":"openstreetmap","attribution":"© OpenStreetMap contributors","license":"Open Database Licence","url":"https://www.openstreetmap.org/copyright"},"country_code":"bh","state":"Capital","lon":50.616502,"lat":26.157757,"result_type":"street","formatted":"Road 832, Bahrain","address_line1":"Road 832","address_line2":"Bahrain","rank":{"popularity":1.9405618540059437},"place_id":"5194f59b89e94e4940590fb743c362283a40f00103f901e8881b0100000000920308526f616420383332"},"bbox":[50.61642,26.157264,50.61668,26.158086]},{"type":"Feature","geometry":{"type":"Point","coordinates":[50.616174,26.157533]},"properties":{"name":"Road 824","street":"Road 824","distance":222.4248319864949,"country":"Bahrain","datasource":{"sourcename":"openstreetmap","attribution":"© OpenStreetMap contributors","license":"Open Database Licence","url":"https://www.openstreetmap.org/copyright"},"country_code":"bh","state":"Capital","lon":50.616174,"lat":26.157533,"result_type":"street","formatted":"Road 824, Bahrain","address_line1":"Road 824","address_line2":"Bahrain","rank":{"popularity":1.9405618540059437},"place_id":"51a05225cade4e494059700a2b1554283a40f00103f901f1881b0100000000920308526f616420383234"},"bbox":[50.615814,26.157415,50.616542,26.157629]},{"type":"Feature","geometry":{"type":"Point","coordinates":[50.620121,26.155793]},"properties":{"name":"Awal","distance":228.35563436937684,"country":"Bahrain","datasource":{"sourcename":"openstreetmap","attribution":"© OpenStreetMap contributors","license":"Open Database Licence","url":"https://www.openstreetmap.org/copyright"},"street":"Awal","country_code":"bh","state":"Capital","lon":50.620121,"lat":26.155793,"result_type":"amenity","formatted":"Awal, Bahrain","address_line1":"Awal","address_line2":"Bahrain","rank":{"popularity":1.9321029185567853},"place_id":"510a48fb1f604f4940591bf2cf0ce2273a40f00102f90168626f13000000009203044177616c"},"bbox":[50.6194187,26.1547791,50.6211514,26.1565751]},{"type":"Feature","geometry":{"type":"Point","coordinates":[50.619482,26.157871]},"properties":{"name":"Road 723","street":"Road 723","distance":239.25201915640312,"country":"Bahrain","datasource":{"sourcename":"openstreetmap","attribution":"© OpenStreetMap contributors","license":"Open Database Licence","url":"https://www.openstreetmap.org/copyright"},"country_code":"bh","state":"Capital","lon":50.619482,"lat":26.157871,"result_type":"street","formatted":"Road 723, Bahrain","address_line1":"Road 723","address_line2":"Bahrain","rank":{"popularity":1.9405135342542503},"place_id":"51f73aa92f4b4f494059a0fcdd3b6a283a40f00103f901c9881b0100000000920308526f616420373233"},"bbox":[50.61922,26.15652,50.619834,26.159233]},{"type":"Feature","geometry":{"type":"Point","coordinates":[50.619955,26.155072]},"properties":{"name":"Avenue 1","street":"Avenue 1","distance":244.553149714086,"country":"Bahrain","datasource":{"sourcename":"openstreetmap","attribution":"© OpenStreetMap contributors","license":"Open Database Licence","url":"https://www.openstreetmap.org/copyright"},"country_code":"bh","state":"Capital","lon":50.619955,"lat":26.155072,"result_type":"street","formatted":"Avenue 1, Bahrain","address_line1":"Avenue 1","address_line2":"Bahrain","rank":{"popularity":1.7593819833865791},"place_id":"51effe78af5a4f4940597b8670ccb2273a40f00103f90178f18801000000009203084176656e75652031"},"bbox":[50.61655,26.14822,50.620704,26.160984]}]}
2 Likes

Thanks!

What did you receive back in your text input, and is that your society’s name?

1 Like

If you paste all of that into Best JSON Viewer and JSON Beautifier Online and click Tree Viewer, you can expand the properties on the right side to find that the text input value would be Road 849.

I’m not familiar with the idea of a geographical “society.” So I’m not sure what I’d report back. But you can see all of the data @muneer got on that JSON viewer website.

Probably the closest thing I can think of in the U.S. is a neighborhood… smaller than a city but larger than a house/apartment complex. I don’t think that API is going to return a neighborhood name. Where in the JSON response did you find the society name for your location?

2 Likes

By society, I mean apartment complex or community. I found it in the properties<name part of the second list item. Basically a group of houses where you can consider every house your distant neighbour. I’m not sure I’m being clear at the moment, but I’m not familiar with how you group house in the US. Yeah, a neighbourhood works too, or a particular street. Though I’m not talking about house names. For BookARead, I want users to be able to see books only within their apartment complex, so it’s easy for them to collect and lend books. Many people spell the same place differently, so I wanted the location sensor to retrieve their location and send it to the API, and get the society name back. Since I’m getting my apartment complex name in the second list item, I’m wondering if that gives (neighbourhood/street) for everyone, in different areas. Hope you understood the basic outline.

image
Dictionary definition of what I mean.

2 Likes

Okay, that makes sense.

We don’t typically use a housing/apartment complex name very often in the U.S. Sure, an apartment complex would have a specific name but people are more likely to say they live in a particular neighborhood or city.

You can actually get different API responses at their website (Geocoding API Playground by Geoapify) by clicking on “Reverse geocoding” and then clicking on the map… anywhere in the world. It generates JSON so there’s not really a need to test this with blocks.

2 Likes

Here’s an example not too far from where I live in California:

{“type”:“FeatureCollection”,“features”:[{“type”:“Feature”,“geometry”:{“type”:“Point”,“coordinates”:[-122.302419,37.913815]},“properties”:{“housenumber”:“7002”,“street”:“Moeser Ln”,“distance”:14.314842686599187,“country”:“United States”,“county”:“Contra Costa County”,“datasource”:{“sourcename”:“openaddresses”,“attribution”:“© OpenAddresses contributors”,“license”:“BSD-3-Clause License”},“country_code”:“us”,“postcode”:“94530”,“state”:“California”,“city”:“El Cerrito”,“lon”:-122.302419,“lat”:37.913815,“result_type”:“building”,“formatted”:“7002 Moeser Ln, El Cerrito, CA 94530, United States of America”,“address_line1”:“7002 Moeser Ln”,“address_line2”:“El Cerrito, CA 94530, United States of America”,“state_code”:“CA”,“rank”:{“popularity”:4.25756810422202},“place_id”:“5119ac38d55a935ec05910ccd1e3f7f44240”}}]}

That gets formatted as this:

There’s not any sort of “society” equivalent there. Not even a neighborhood name.

2 Likes

Ah, extremely sorry for the confusion. As I said, as long as the 2nd item in the list is the close to apartment complex or something like that, then that’s fine.

I didn’t know about the ‘click on the map’ feature!

Edit: Exactly what I want is to be able to filter until ‘amenity’. But that’s only possible with geocoding and not reverse geocoding. Is there a way to do this? Maybe a different API?

1 Like

Right but you and @muneer both had a properties–>name value. My JSON didn’t have the “name” value at all.

2 Likes

I’m not sure this is helpful but when I designed my Air Quality app last year, I used an API to determine the closest landmark. So something like a famous place or park or museum, etc. I think I used Google Places API but I could double-check if that interests you.

2 Likes

That works too. Since people have to go to the book owner’s house to collect it, the nearest landmark as the key for showing books available could mean a journey of 4-5 km. But it would be great if you could check. Thanks for all the help!

1 Like

I’m pretty sure it was the “point of interest” value from the Google Places API:

2 Likes