I have an android app that gets the lat&long from the device and uses googles reverse geocoding api to give back an address. Everything was working fine for some time but now all of a sudden I get zero_results/
I replicate it in my browser the request is:
https://maps.googleapis.com/maps/api/geocode/json?latlng=31.783783783783782,35.22879215957073&key=MY_KEY
but if I change it to:
https://maps.googleapis.com/maps/api/geocode/json?latlng=31.78,35.22&key=MY_KEY
which is just shortening the lat&lng to 2 decimals it works, but say if I round it to 2 decimals:
https://maps.googleapis.com/maps/api/geocode/json?latlng=31.78,35.23&key=MY_KEY
It doesnt work!!!
I cant rim it without rounding it, but now i am afraid in another case it wont work, I don't know what is going on with the API, everything was working fine before.
Any help solving this would be appreciated.
Thanks
This is because Google gives no support for disputed areas (such as Kinmen County, West Bank, Crimea, etc.). ZERO_RESULTS is the intended behaviour.
You can see the problem in google public issue tracker at https://issuetracker.google.com/issues/35826813
The bad news, your point is at the DMZ. As stated above: Google Reverse Geocoding won't work near the 1949 armistice lines (and not in what used to be Jordanian territories 1949-1967).
The not-so-bad news: There may be some kind of a workaround that's feasible for some: OpenStreetMap can also provide reverse geolocation. Your coordinate:
https://nominatim.openstreetmap.org/reverse?&format=jsonv2&lat=31.779975&lon=35.227901
Yields
{
"place_id": 199263301,
"licence": "Data © OpenStreetMap contributors, ODbL 1.0. https://osm.org/copyright",
"osm_type": "relation",
"osm_id": 7880713,
"lat": "31.7782568",
"lon": "35.2315827592487",
"place_rank": 30,
"category": "historic",
"type": "heritage",
"importance": 0,
"addresstype": "historic",
"name": "Old City of Jerusalem and its Walls",
"display_name": "Old City of Jerusalem and its Walls, HaOmer, Jewish Quarter, Old City, Jerusalem, Jerusalem District, no, Israel",
"address": {
"address29": "Old City of Jerusalem and its Walls",
"footway": "HaOmer",
"suburb": "Old City",
"city": "Jerusalem",
"state": "Jerusalem District",
"postcode": "no",
"country": "Israel",
"country_code": "il"
},
"boundingbox": [
"31.7728081",
"31.7837416",
"35.2257013",
"35.2375582"
]
}
As you can see, they may be off by quite a few hundreds of meters. In this case (I was mean, choosing a case that augments the issue) it spells 15min diversion by foot, and no way by car.
Some may find it tolerable. For others it means sending someone to the wrong place.
On the other hand, as mentioned before, I did pick a nasty case. In most cases OSM are pretty much accurate to a few meters.
I just want to add that on 1/29/2018 I also started experiencing random results from the API. My code has been working great for more for a year. Now I can send a request with a well-defined location (not reverse; I start with an address or intersection in search of coordinates and geopolitical info) and I get no results. I can send again- no results. And I can send again- and I GET RESULTS! Same exact query, with differing responses. I think the root cause for my
Related
I am currently developing a website for a client. It consists of users being able to upload pictures to be shown in a gallery on the site.
The problem we have is that when a user uploads an image it would obviously need to be verified to make sure it is safe for the website (no pornographic or explicit pictures). However my client would not like to manually have to accept every image that is being uploaded as this would be time consuming and the users' images would not instantly be online.
I am writing my code in PHP. If needs be I could change to ASP.net or C#. Is there any way that this can be done?
2019 Update
A lot has changed since this original answer way back in 2013, the main thing being machine learning. There are now a number of libraries and API's available for programmatically detecting adult content:
Google Cloud Vision API, which uses the same models Google uses for safe search.
NSFWJS uses TensorFlow.js claims to achieve ~90% accuracy and is open source under MIT license.
Yahoo has a solution called Open NSFW under the BSD 2 clause license.
2013 Answer
There is a JavaScript library called nude.js which is for this, although I have never used it. Here is a demo of it in use.
There is also PORNsweeper.
Another option is to "outsource" the moderation work using something like Amazon Mechanical Turk, which is a crowdsourced platform which "enables computer programs to co-ordinate the use of human intelligence to perform tasks which computers are unable to do". So you would basically pay a small amount per moderation item and have an outsourced actual human to moderate the content for you.
The only other solution I can think of is to make the images user moderated, where users can flag inappropriate posts/images for moderation, and if nobody wants to manually moderate them they can simply be removed after a certain number of flags.
Here are a few other interesting links on the topic:
http://thomas.deselaers.de/publications/papers/deselaers_icpr08_porn.pdf
http://www.naun.org/multimedia/NAUN/computers/20-462.pdf
What is the best way to programmatically detect porn images?
The example below does not give you 100% accurate results but it should help you a least a bit and works out of the box.
<?php
$url = 'http://server.com/image.png';
$data = json_decode(file_get_contents('http://api.rest7.com/v1/detect_nudity.php?url=' . $url));
if (#$data->success !== 1)
{
die('Failed');
}
echo 'Contains nudity? ' . $data->nudity . '<br>';
echo 'Nudity percentage: ' . $data->nudity_percentage . '<br>';
If you are looking for an API-based solution, you may want to check out Sightengine.com
It's an automated solution to detect things like adult content, violence, celebrities etc in images and videos.
Here is an example in PHP, using the SDK:
<?php
$client = new SightengineClient('YourApplicationID', 'YourAPIKey');
$output = $client>check('nudity')>image('https://sightengine.com/assets/img/examples/example2.jpg');
The output will then return the classification:
{
"status": "success",
"request": {
"id": "req_VjyxevVQYXQZ1HMbnwtn",
"timestamp": 1471762434.0244,
"operations": 1
},
"nudity": {
"raw": 0.000757,
"partial": 0.000763,
"safe": 0.999243
},
"media": {
"id": "med_KWmB2GQZ29N4MVpVdq5K",
"uri": "https://sightengine.com/assets/img/examples/example2.jpg"
}
}
Have a look at the documentation for more details: https://sightengine.com/docs/#nudity-detection
(disclaimer: I work there)
There is a free API that detects adult content (porn, nudity, NSFW).
https://market.mashape.com/purelabs/sensitive-image-detection
We've using it on our production environment and I would say it works pretty good so far. There are some false detections though, it seems they prefer to mark the image as unsafe if they are unsure.
It all depends on the level of accuracy you are looking for, simple skin tone detection (like nude.js) will prob get you 60-80% accuracy on a generous sample set, for anything more accurate than that, let's say 90-95%, you are going to need some specialized computer vision system with an evolving model that is revised over time. For the latter you might want to check out http://clarifai.com or https://scanii.com (which I work on)
Microsoft Azure has a very cool API called Computer Vision, which you can use for free (either through the UI or programmatically) and has tons of documentation, including for PHP.
It has some amazingly accurate (and sometimes humorous) results.
Outside of detecting adult and "racy" material, it will read text, guess your age, identify primary colours, etc etc.
You can try it out at azure.microsoft.com.
Sample output from a "racy" image:
FEATURE NAME: VALUE:
Description { "tags": [ "person", "man", "young", "woman", "holding",
"surfing", "board", "hair", "laying", "boy", "standing",
"water", "cutting", "white", "beach", "people", "bed" ],
"captions": [ { "text": "a man and a woman taking a selfie",
"confidence": 0.133149087 } ] }
Tags [ { "name": "person", "confidence": 0.9997446 },
{ "name": "man", "confidence": 0.9587285 },
{ "name": "wall", "confidence": 0.9546831 },
{ "name": "swimsuit", "confidence": 0.499717563 } ]
Image format "Jpeg"
Image dimensions 1328 x 2000
Clip art type 0
Line drawing type 0
Black and white false
Adult content true
Adult score 0.9845981
Racy true
Racy score 0.964191854
Categories [ { "name": "people_baby", "score": 0.4921875 } ]
Faces [ { "age": 37, "gender": "Female",
"faceRectangle": { "top": 317, "left": 1554,
"width": 232, "height": 232 } } ]
Dominant color background "Brown"
Dominant color foreground "Black"
Accent Color #0D8CBE
I have an array of JSON real Points of Interest that came from an API (generated by Java) taken from a PostgreSQL database:
[
{
"code": 18554,
"lat": 43.36161686223077,
"lon": 3.15837302430637,
"taxon": {
"popularNameEN": "Moon trefoil",
"media": {
"thumbnail": "//upload.wikimedia.org/wikipedia/commons/thumb/8/81/Cistus_creticus_1.jpg/240px-Moon_trefoil.jpg"
}
}
},
{
"code": 13826,
"lat": 42.36162882111323,
"lon": 3.158355343054932,
"taxon": {
"popularNameEN": "Rock rose",
"media": {
"thumbnail": "//upload.wikimedia.org/wikipedia/commons/thumb/c/cc/Cistus_creticus_RJB2.JPG/240px-Cistus_creticus_RJB2.JPG"
}
}
}
]
(16000 PoI in an area of 14 hectares).
Currently my app draw them in a 2d regular map (with Leaflet) with the name and a thumbnail (I already have a function that show just the 8 closest, not all 16000).
I want to show same information in a simple and easy Augmented Reality way in Android phones.
I don't care if the result is not perfect because the compass, or anything. I care to use 100% free and open source software and avoid to use an external API, if it is possible. I need just something simple for a show to my client but maybe also something enough good to continue improving my app in the future. What framework/libraries should I use for this and how?
You can start with Google's AR kit.
https://developers.google.com/ar
It is easy and self-explanatory, but for now, it has limited support for devices.
We are using the nearby search feature as described here (https://developers.google.com/places/web-service/search) to perform auto check-in in Android as well as iOS mobile apps.
However, when we call the web API, many of the nearby locations do not show up in our results. At the same time, I do receive notifications from the Google Maps App on my Android phone, asking if i am at the venue meaning the google maps app correctly detects my location.
As an example I was dining at Nando's located at:
https://www.google.com/maps/place/Nando's+PERi-PERi/#41.8854864,-87.6238967,19.85z/data=!4m5!3m4!1s0x0:0x714d54c7334f4af6!8m2!3d41.885548!4d-87.624252
But when I called the nearby search, Nando's did not show up in my list of nearby places. I checked and my gps coordinates were correct and google maps was able to detect my location and check me in.
Anybody know why this happens? Is there a workaround or a solution for this problem?
You didn't post the Places API query, so it is difficult to say what is wrong in your application.
I tried it myself and it worked for me as expected. Let suppose I have a GPS coordinate 41.885565,-87.62425, this is a position more or less of the Nando's you mentioned in the description (have a look at Geocoder tool):
https://google-developers.appspot.com/maps/documentation/utils/geocoder/#q%3D41.885565%252C-87.62425
Now I can create a nearby search request for location 41.885565,-87.62425 with results rank by distance, so the nearest place will be the first in response and also we have to apply a type parameter in the request according to the documentation:
If rankby=distance (described under Optional parameters below) is specified, then one or more of keyword, name, or type is required.
The resulting request is
https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=41.885565%2C-87.62425&rankby=distance&type=restaurant&key=MY_API_KEY
With this request I get Nando's (place ID ChIJ9xIeWq8sDogR9kpPM8dUTXE) as the first item in the response
"results":[
{
"geometry":{
"location":{
"lat":41.8855475,"lng":-87.6242518
},
"viewport":{
"northeast":{
"lat":41.8870082302915,"lng":-87.62290226970849
},
"southwest":{
"lat":41.8843102697085,"lng":-87.6256002302915
}
}
},
"icon":"https://maps.gstatic.com/mapfiles/place_api/icons/restaurant-71.png",
"id":"a29ff7d92a100fd6f5a8c0e34dff84806838f2d9",
"name":"Nando's PERi-PERi",
"opening_hours":{
"open_now":false,
"weekday_text":[
]
},
"photos":[
{
"height":3036,
"html_attributions":[
"Marco Laure"
],
"photo_reference":"CmRaAAAAwbEPFsgrrjKVrplwBAAmKhKe5CkFX9wn_x1ZF9d6K8rRdT8tRUiW23-qEGLwbuf1wePdUkSrSN21a8r696kXGv6KYG42mI7RaDf2n80iLJlDVtEXys1KK4Hn9_nebsLwEhC6CQemKH3oHLe52i5m-JzOGhQoYbUFTntC5IuEzvASfjPvhDgr_g",
"width":4048
}
],
"place_id":"ChIJ9xIeWq8sDogR9kpPM8dUTXE",
"price_level":1,
"rating":4.2,
"reference":"CmRRAAAARrKCjwMLRvvXncBVw9pCf8RNq1GpfjDrHD8Jh_du12zBJxJ_eaGidizxAny31qn24BgZDpab346A3_QYbgaUMMZOnratR9XBNkQNS1a-DCPSFggzNjsUoOl_QQkhQU-DEhDExmV2z_pyXAkAoxRzIAVQGhT5kjoH3myVM7-vraAlw0EG512ykw",
"scope":"GOOGLE",
"types":[
"restaurant","food","point_of_interest","establishment"
],
"vicinity":"117 East Lake Street, Chicago"
},
I hope this helps!
Is it possible to get a response (true or false) if are a traffic jam from your position to your destination, using google maps android API? Or using google maps web api?
Can not find anythink about that.
I believe there is no direct Google endpoint that can answer this question. However, you can implement a workaround using a Distance Matrix API web service or Directions API web service. If you specify a departure time in the request, the response will contain fields duration and duration_in_traffic. So you can figure out if duration_in_traffic is much bigger than duration and decide if there is a traffic jam somewhere on this route.
For example,
I execute Distance Matrix API request for two points in Barcelona
https://maps.googleapis.com/maps/api/distancematrix/json?origins=av%20Diagonal%20198%2C%20Barcelona&destinations=plaza%20Espa%C3%B1a%2C%20Barcelona&departure_time=now&key=MY_API_KEY
The response is
{
"destination_addresses":[
"Av. del Paraŀlel, s/n, 08015 Barcelona, Spain"
],
"origin_addresses":[
"Avinguda Diagonal, 198, 08018 Barcelona, Spain"
],
"rows":[
{
"elements":[
{
"distance":{
"text":"6.0 km",
"value":6049
},
"duration":{
"text":"17 mins",
"value":1035
},
"duration_in_traffic":{
"text":"19 mins",
"value":1134
},
"status":"OK"
}
]
}
],
"status":"OK"
}
Comparing duration_in_traffic and duration from my response I can say that currently there are no traffic jams on this route.
I hope this helps!
I have searched quite a bit without luck so far.
The Android Geocoder returns the android.location.Address object.
The city, as far as I understood, should be returned in getLocality().
It seems within USA this works well, outside not.
I am writing an international app and struggle to find a solution to find out the city of a geolocation.
Here the output from Czech Republic/Prague :
Address[addressLines=
[0:"Psohlavců 1764/2",
1:"147 00 Prague-Prague 4",
2:"Czech Republic"],
feature=2,
admin=Hlavní město Praha,
sub-admin=Prague,
locality=null,
thoroughfare=Psohlavců,
postalCode=147 00,
countryCode=CZ,
countryName=Czech Republic,
hasLatitude=true,
latitude=50.0276543,
hasLongitude=true,
longitude=14.4183926,
phone=null,
url=null,
extras=null]
locality is null, the city is within sub-admin !
The address itself is ok, so the geocoder server seems to know the city.
Here some ore random EU examples but locality works partly:
Address[addressLines=[0:"Nad lesem 440/34",1:"147 00 Prague-Prague 4",2:"Czech Republic"],feature=34,admin=Hlavní město Praha,sub-admin=Prague,locality=null,thoroughfare=Nad lesem,postalCode=147 00,countryCode=CZ,countryName=Czech Republic,hasLatitude=true,latitude=50.02424,hasLongitude=true,longitude=14.4117568,phone=null,url=null,extras=null]
Address[addressLines=[0:"Hauner Straße 4",1:"84431 Heldenstein",2:"Germany"],feature=4,admin=null,sub-admin=null,locality=Heldenstein,thoroughfare=Hauner Straße,postalCode=84431,countryCode=DE,countryName=Germany,hasLatitude=true,latitude=48.2540274,hasLongitude=true,longitude=12.3413535,phone=null,url=null,extras=null]
Address[addressLines=[0:"Igler Straße",1:"6020 Innsbruck",2:"Austria"],feature=Igler Straße,admin=Tyrol,sub-admin=Innsbruck,locality=Innsbruck,thoroughfare=Igler Straße,postalCode=6020,countryCode=AT,countryName=Austria,hasLatitude=true,latitude=47.2465698,hasLongitude=true,longitude=11.4054237,phone=null,url=null,extras=null]
Address[addressLines=[0:"Durnberg 24",1:"5724 Stuhlfelden",2:"Austria"],feature=24,admin=Salzburg,sub-admin=Zell am See District,locality=null,thoroughfare=Durnberg,postalCode=5724,countryCode=AT,countryName=Austria,hasLatitude=true,latitude=47.3233373,hasLongitude=true,longitude=12.4960482,phone=null,url=null,extras=null]
Address[addressLines=[0:"U Roháčových kasáren 14",1:"100 00 Prague 10",2:"Czech Republic"],feature=14,admin=Hlavní město Praha,sub-admin=Prague,locality=Prague 10,thoroughfare=U Roháčových kasáren,postalCode=null,countryCode=CZ,countryName=Czech Republic,hasLatitude=true,latitude=50.0704092,hasLongitude=true,longitude=14.4673473,phone=null,url=null,extras=null]
Maybe the fault is on me, but to me it seems like depending on the country and area the city will be found in different fields.
However, the address itself mostly seems to be good enough to send a postal letter.
Has someone written a clever function which tries to make more sense out of the Geocoder results ? It's a pity to see that Google has the information stored but does not provide it properly.
Going to close my question, solved it with a workaround.
Using the suggestion from dannyroa
String city="unknown";
if (address.getLocality() != null) city=address.getLocality();
else
if (address.getSubAdminArea() != null) city=address.getSubAdminArea();
This could be further extended by getting the city information out of the second address line.
removing the postal code and taking the remainder, but this information is not unique within a city and could change depending on the district/zone.