Request buildings around and area osm android - android

I would like to perform a request to OSM Overpass Turbo API or Overpass API from and Android Application so i can get the buildings around and area using JSON.
Something similar to
http://overpass-turbo.eu/ with the query presented below:
[out:json][timeout:25];
// gather results
(
// query part for: “building”
way["building"](37.98350674557998,23.72600823640823,37.98552989685638,23.728837966918945);
relation["building"](37.98350674557998,23.72600823640823,37.98552989685638,23.728837966918945);
);
// print results
out body;
>;
out skel qt;
The thing is that i need the results in geojson like the result below but i cannot find any query that gives me the below result.
{
"type": "FeatureCollection",
"generator": "overpass-turbo",
"copyright": "The data included in this document is from www.openstreetmap.org. The data is made available under ODbL.",
"timestamp": "2015-03-23T20:41:02Z",
"features": [
{
"type": "Feature",
"id": "relation/2604192",
"properties": {
"#id": "relation/2604192",
"building": "yes",
"type": "multipolygon"
},
"geometry": {
"type": "Polygon",
"coordinates": [
[
[
23.7319885,
37.9752441
],
[
23.7319787,
37.9751612
],
[
23.7319494,
37.9751641
],
[
23.7319372,
37.9748376
],
[
23.7319702,
37.9748318
],
]
]
}
},
I get only results with nodes but not with geometry.
{
"type": "way",
"id": 25107859,
"nodes": [
2373953582,
2373953586,
2373953592,
2373953599,
2373953597,
2373953636,
2373953633,
2373953626,
273319309,
2373953582
],
"tags": {
"building": "yes"
}
},
After some useful comments (thanks scai) i found out that overpass turbo is not queried automatically. Therefore i searched for overpass api and i found out this site with a query for buildings to overpass api exporting to GeoJSON but i does not work (though the xml query in the site works but i need json). Anyone has a query that works so i can follow it?
http://inasafe.org/en/developer-docs/osm_building_downloads.html
http://overpass-api.de/api/interpreter?data=[out:json];(node[%23building%22=%22yes%22](-6.185440796831979,106.82374835014343,-6.178966266481431,106.83127999305725);way[%22building%22=%22yes%22](-6.185440796831979,106.82374835014343,-6.178966266481431,106.83127999305725);relation[%22building%22=%22yes%22](-6.185440796831979,106.82374835014343,-6.178966266481431,106.83127999305725););(._;%3E;);out%20body;

Related

Integrating PayPal Checkout in an Android app

I am integrating Paypal checkout in an Android App using REST APIs provided by Paypal and my country is India so I am following this guide from PayPal.
How I did as per docs:
Get access-token (/v1/oauth2/token) for further api calls.
Use the Create Order API to create a payment (v2/checkout/orders)and in the response we will get approval url at where you need to redirect user to make the payment.
Now my question is how do I know if payment transaction was successful or not in mobile app because I am using WebView in my app to load approval url.
Order is created like this and I load href inside webview:
{
"id": "1KK44573EX7352015",
"status": "CREATED",
"links": [
{
"href": "https://www.sandbox.paypal.com/checkoutnowtoken=1KK44573EX7352015",
"rel": "approve",
"method": "GET"
}
]
}
I did this way:
As soon as Payment is successfully completed by customer the return_url gets called with query parameters : PayerID & token(orderID). At that time we can update user's payment status in our database (Amount is not deducted yet still because order is yet not approved or captured).
After that we can capture our order (Make sure invoice-id is not duplicate) otherwise status will be not completed.
If order is not approved on the time of capture we get this kind of error:
{
"name": "UNPROCESSABLE_ENTITY",
"details": [
{
"issue": "ORDER_NOT_APPROVED",
"description": "Payer has not yet approved the Order for payment. Please redirect the payer to the 'rel':'approve' url returned as part of the HATEOAS links within the Create Order call or provide a valid payment_source in the request."
}
],
"message": "The requested action could not be performed, semantically incorrect, or failed business validation.",
"debug_id": "47af43e..",
"links": [
{
"href": "https://developer.paypal.com/docs/api/orders/v2/#error-ORDER_NOT_APPROVED",
"rel": "information_link",
"method": "GET"
}
]
}
If there is duplicate invoice-id you will see error at the time of capture:
{
"name": "UNPROCESSABLE_ENTITY",
"details": [
{
"issue": "DUPLICATE_INVOICE_ID",
"description": "Duplicate Invoice ID detected. To avoid a potential duplicate transaction your account setting requires that Invoice Id be unique for each transaction."
}
],
"message": "The requested action could not be performed, semantically incorrect, or failed business validation.",
"debug_id": "86e0cc7f....",
"links": [
{
"href": "https://developer.paypal.com/docs/api/orders/v2/#error-DUPLICATE_INVOICE_ID",
"rel": "information_link",
"method": "GET"
}
]
}
If there is currency based issue:
{
"name": "UNPROCESSABLE_ENTITY",
"details": [
{
"location": "body",
"issue": "CURRENCY_NOT_SUPPORTED",
"description": "Currency code is not currently supported. Please refer https://developer.paypal.com/docs/integration/direct/rest/currency-codes/ for list of supported currency codes."
}
],
"message": "The requested action could not be performed, semantically incorrect, or failed business validation.",
"debug_id": "d666b5e5eb0c0",
"links": [
{
"href": "https://developer.paypal.com/docs/api/orders/v2/#error-CURRENCY_NOT_SUPPORTED",
"rel": "information_link",
"method": "GET"
}
]
}
If your order is successfully captured with status as COMPLETED:
{
"id": "8G0042477K865063U",
"status": "COMPLETED",
"purchase_units": [
{
"reference_id": "default",
"shipping": {
"name": {
"full_name": "John Doe"
},
"address": {
"address_line_1": "10, east street",
"address_line_2": "first building",
"admin_area_2": "Mumbai",
"admin_area_1": "Maharashtra",
"postal_code": "400029",
"country_code": "NZ"
}
},
"payments": {
"captures": [
{
"id": "4K670967VH2547504",
"status": "PENDING",
"status_details": {
"reason": "RECEIVING_PREFERENCE_MANDATES_MANUAL_ACTION"
},
"amount": {
"currency_code": "NZD",
"value": "170.00"
},
"final_capture": true,
"seller_protection": {
"status": "ELIGIBLE",
"dispute_categories": [
"ITEM_NOT_RECEIVED",
"UNAUTHORIZED_TRANSACTION"
]
},
"invoice_id": "INV-1234567888",
"links": [
{
"href": "https://api.sandbox.paypal.com/v2/payments/captures/4K670967VH2547504",
"rel": "self",
"method": "GET"
},
{
"href": "https://api.sandbox.paypal.com/v2/payments/captures/4K670967VH2547504/refund",
"rel": "refund",
"method": "POST"
},
{
"href": "https://api.sandbox.paypal.com/v2/checkout/orders/8G0042477K865063U",
"rel": "up",
"method": "GET"
}
],
"create_time": "2020-10-31T13:35:58Z",
"update_time": "2020-10-31T13:35:58Z"
}
]
}
}
],
"payer": {
"name": {
"given_name": "Sumit",
"surname": "Shukla"
},
"email_address": "testg32#gmail.com",
"payer_id": "VW87TYSM2GMZ4",
"address": {
"address_line_1": "10, east street",
"admin_area_2": "Mumbai",
"admin_area_1": "Maharashtra",
"postal_code": "400029",
"country_code": "NZ"
}
},
"links": [
{
"href": "https://api.sandbox.paypal.com/v2/checkout/orders/8G0042477K865063U",
"rel": "self",
"method": "GET"
}
]
}
After that you can redirect user to thank you page and update mobile app screen based on database values.

Where to find the components key in the link of execute command of azure iot central

**[11:12] Umer Saleem
Working on it, sir in this example link what is the components name and how to find it
POST https://{subdomain}.{centralDnsSuffixInPath}/api/preview/devices/{device_id}/components/{component_name}/commands/{command_name}
**
To find out what components you have for this device, you can do a GET request to
https://{subdomain}.{centralDnsSuffixInPath}/api/preview/devices/{device_id}/components/
This will show you the components, a sample response can be:
{
"value": [
{
"#id": "urn:machine:MyMachine:lxhc64xu:1",
"#type": [
"InterfaceInstance"
],
"name": "cb_7d7",
"displayName": "Interface"
},
{
"#id": "urn:machine:MyMachine:_lyh_e2x:1",
"#type": [
"InterfaceInstance"
],
"name": "cb_282",
"displayName": "Properties"
}
]
}
The name of the {component} is the name of the value that you get in the response. In my example, you can use "cb_7d7" or "cb_282". They are the names of your interfaces.

Google custom search result have only results from google map

I have recently implemented Google Custom search. I am getting a result but it every link in it whether it is for website or image or thumbnail, it is from maps.
example result -
{
"kind": "customsearch#result",
"title": "Saga Tree",
"htmlTitle": "Saga \u003cb\u003eTree\u003c/b\u003e",
"link": "https://***www.google.com/mymaps***/viewer?mid=1yF1gMCZhBaeEouT9GB-7bQqXmuw&hl=en",
"formattedUrl": "***https://www.google.com/mymaps***/viewer?mid...7bQqXmuw&hl...",
"pagemap": {
"cse_thumbnail": [
{
"width": "221",
"height": "228",
"src": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcR2SZoZ2AF7PUVw5wGucLb5Hd4k1Bwkt3x6__ed8E_01Mlq5Fwd7nKpKI2b"
}
],
"website": [
{
"name": "Saga Tree",
"description": "Saga Tree",
"url": "***https://www.google.com/maps/d/viewer***?mid=1yF1gMCZhBaeEouT9GB-7bQqXmuw&hl=en",
"image": "***https://www.google.com/maps***/d/thumbnail?mid=1yF1gMCZhBaeEouT9GB-7bQqXmuw&hl=en"
}
],
"metatags": [
{
"viewport": "initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=0,width=device-width",
"og:type": "website",
"og:title": "Saga Tree",
"og:description": "Saga Tree",
"og:url": "***https://www.google.com/maps***/d/viewer?mid=1yF1gMCZhBaeEouT9GB-7bQqXmuw&hl=en",
"og:image": "***https://www.google.com/maps***/d/thumbnail?mid=1yF1gMCZhBaeEouT9GB-7bQqXmuw&hl=en",
"twitter:card": "summary_large_image",
"twitter:title": "Saga Tree",
"twitter:description": "Saga Tree",
"twitter:image:src": "https://www.google.com/maps/d/thumbnail?mid=1yF1gMCZhBaeEouT9GB-7bQqXmuw&hl=en"
}
],
"cse_image": [
{
"src": "https://www.google.com/maps/d/thumbnail?mid=1yF1gMCZhBaeEouT9GB-7bQqXmuw&hl=en"
}
]
}
}
This is with every result. I want results as if I have searched it in the browser.
This usually happens when the Custom Search API performs search only with the default included site ( www.google.com ). This is the default. To change it go to Basics -> Sites to Search under your Custom Search engine and choose "Search the entire web but emphasise included sites" instead of the default "Search only included sites".
Also ensure Image Search is enabled under Basics.

Parsing JSON in android to add markers in Google Map

I have an url,get and response given. I have to parse the JSON and show the locations in Map in android. I dont need you to code. I am new in JSON. please tell me some steps how i can do that. how should i start and which steps i should take?
Url: "Some url"
Sending data:
{
"tag": "getAvailableDriver",
"lat": 41.022348,
"lng": -91.966721
}
RESPONSE:
{
"posts": [
{
"success": "1",
"driver": [
{
"id": "768",
"lat": "41.022848",
"lon": "-91.966884",
"recorded_datetime": "2014-07-20 20:18:03",
"user_id": "403",
"cabbi_state": "OnJob",
"vehicleType": "Black Cab",
"driver_name": "black cab driver",
"pic_name": "userimage/403.jpg",
"rating": "0",
"car_model": "this",
"number_sit": "4",
"distance": 0.035574527536789
}
],
"operator": [],
"nearestdistance": [
{
"distance": 0.03541809,
"time": 5
}
],
"car_models": [
"Taxi"
]
}
]
}
I just want anyone of you to guide me or show me the way. And also please someone tell me what will be the use of "send data" here. What is the use? I promise i will not ask any basic questions after i catch the grip. Help me please.
You can save the parsed data in an array, and for what I can see, there's a lot of tags in the JSON object. I suggest you to create an object of the type "Driver" or "Car", and then save all the data in that object. Once you have the data parsed and saved in an Array of the type of your object (Let's say an array of "Drivers" then you can use the info to add it into the Map.

Places Autocomplete API to get GPS coordinates from address entered

I have an address field in my app where the user needs to enter the required address. I have used google Geocoder to get the GPS coordinates of the address . But now I want to make it easier for the user by using Places Autocomplete . But Places Autocomplete only returns the address , Id and reference of the place .
Is there a way to get the GPS coordinates of the address selected by the user using Places Autocomplete API ? Do I have to use Geocoder again after the user selects his address from Places Autocomplete ?
Or Should I use Places API again after the user selects his address to get the GPS coordinates of the address ? I dont want to send multiple requests to the Places API because of the usage limits in place . . This is the expected response from Places API ..There is no GPS coordinates in the response .
"status": "OK",
"predictions": [ {
"description": "Paris, France",
"id" : "691b237b0322f28988f3ce03e321ff72a12167fd",
"reference": "CiQYAAAA0Q_JA...kT3ufVLDDvTQsOwZ_tc",
"terms": [ {
"value": "Paris",
"offset": 0
}, {
"value": "France",
"offset": 7
} ],
"types": [ "geocode" ],
"matched_substrings": [ {
"offset": 0,
"length": 5
} ]
}, {
"description": "Paris, TX, United States",
"id" : "518e47f3d7f39277eb3bc895cb84419c2b43b5ac",
"reference": "CjQjAAAAHnbxZZ...BDR3iIOFdMTxwo1jHg",
"terms": [ {
"value": "Paris",
"offset": 0
}, {
"value": "TX",
"offset": 7
}, {
"value": "United States",
"offset": 11
} ],
"types": [ "geocode" ],
"matched_substrings": [ {
"offset": 0,
"length": 5
} ]
}, {
"description": "Paris, Ontario, Canada",
"id" : "e7ac9c89d4a590305242b0cb5bf43064027223c9",
"reference": "CjQhAAAAIv_YWYt...F8KZHY36TwMrbyu_g",
"terms": [ {
"value": "Paris",
"offset": 0
}, {
"value": "Ontario",
"offset": 7
}, {
"value": "Canada",
"offset": 16
} ],
"types": [ "geocode" ],
"matched_substrings": [ {
"offset": 0,
"length": 5
} ]
}
You simply use the Place Details part of the Places API where you get the actual place from the reference in each suggestion using the "reference" value. For example:
https://maps.googleapis.com/maps/api/place/details/json?reference=CiQYAAAA0Q_JA...kT3ufVLDDvTQsOwZ_tc&sensor=true&key=AddYourOwnKeyHere
This will give you information about the place including its coordinates (point for a specific location, bounds for an area).

Categories

Resources