Google Directions API and Using maps.google.com give different Response - java

Here - > https://maps.google.com/
I queried for parameters
A : antim chauraha, Indore, Madhya Pradesh, India
B : India Collection, Indore, Madhya Pradesh, India
And using the webservice to get as XML, same response from Direction API
http://maps.googleapis.com/maps/api/directions/xml?origin=ANTIM%20CHAURAHA,Indore,Madhya%20Pradesh,India&destination=INDIA%20COLLECTION,PALSIKAR,Indore,Madhya%20Pradesh,India&sensor=false
Those responses do not match at all. You see the distance, direction or anything.
Am I doing something wrong?

Google Maps uses additional information to locate your "query string". The directions API uses postal addresses (for the most part).
Neither of these looks like a particularly good "address"
A : antim chauraha, Indore, Madhya Pradesh, India
B : India Collection, Indore, Madhya Pradesh, India
Run them through the Google Maps API v3 geocoder, they both resolve to the same place (Indore, Madhya Pradesh, India)
If you need to resolve "places" like that, use the Places API to get coordinates, then use the directions service to get directions between the coordinates.

Basically there is a difference in name and address. Google database can have other symbols for the same location. You can read my answer here: http://www.stackoverflow.com/questions/12788664/google-maps-api-geocode-returns-different-co-ordinates-then-google-maps/12790012#12790012. In the google response the name is what you are looking for and in the placemark object the list of address and location in the google database. You need to loop through the placemark object to find the most similar location.

Related

How to search in firebase database

I'm trying to filter the data from my database using this code:
fdb.orderByChild("title").startAt(searchquery).endAt(searchquery+"\uf8ff").addValueEventListener(valuelistener2);
My database is like this:
"g12" : {
"Books" : {
"-Mi_He4vHXOuKHNL7yeU" : {
"title" : "Technical Sciences P1"
},
"-Mi_He50tUPTN9XDiVow" : {
"title" : "Life Sciences"
},
"-Mi_He51dhQfl3RAjysQ" : {
"title" : "Technical Sciences P2"
}}
While the code works, it only returns the first value that matches the query and doesn't fetch the rest of the data even though it matches.
If I put a "T" as my search query, I just get the first title "Technical Sciences P1 " and don't get the other one with P2
(Sorry for the vague and common question title, it's just I've been looking for a solution for so long)
While the codes works, it only returns the first value that matches the query
That's the expected behavior since Firebase Realtime Database does not support native indexing or search for text fields in database properties.
When you are using the following query:
fdb.orderByChild("title").startAt(searchquery).endAt(searchquery+"\uf8ff")
It means that you are trying to get all elements that start with searchquery. For example, if you have a title called "Don Quixote" and you search for "Don", your query will return the correct results. However, searching for "Quix" will yield no results.
You might consider downloading the entire node to search for fields client-side but this solution isn't practical at all. To enable full-text search of your Firebase Realtime Database data, I recommend you to use a third-party search service like Algolia or Elasticsearch.
If you consider at some point in time to try using Cloud Firestore, please see the following example:
Is it possible to use Algolia query in FirestoreRecyclerOptions?
To see how it works with Cloud Firestore but in the same way, you can use it with Firebase Realtime Database.

Firebase Database Query Data

I am new to Firebase Database, I am making an android app in which the structure of the data is like this :
{
posts={
-Ks4AoL7F-oKtwd3M8Ao={
address=Address of mine,
title=Title ,
subcategory=E-waste, category=Garbage,
time=21-08-2017 07:54 p.m.,
mobileNumber=some mobile number,
comment=hhdhdehsbsbhs,
statusText=Pending,
imagePath=https://firebasestorage.googleapis.com/v0/b/path-to-image
},...
}
So in this structure i want to query the posts on the basis of the mobile number i.e., if the mobile number matches than the current post will be retrieved else skip this post and check for next post and so on...
you can get all the list of data from post object with the help of simple queries which you can find in documentation part of firebase, where you can check for each object's mobile no, accordingly apply the conditions to keep or discard the object.
for more info please look into the link:-
sample to retrieve the data from firebase
You can refer this post and
This

Twitter4j API track and location filter

I'am using Twitter4j API to collect tweets from india. I am applying filter to collect tweets having specific keywords only, but i'am getting all tweets from india region, not having that specific keywords. my code is
FilterQuery filter = new FilterQuery();
String keyword[]= {"flu"};
double [][]location ={{68.1,8.06},{97.41,37.10}};
filter.track(keyword);
filter.locations(location);
twitterstream.addListener(listener);
twitterstream.filter(filter);
how can get tweets from India having "flu" as a part of tweet text.
This is so because twitter filter parameters together do not apply as AND but OR.
Check more here - https://dev.twitter.com/streaming/overview/request-parameters
The twitter API documentation also says so -
Bounding boxes do not act as filters for other filter parameters. For example track=twitter&locations=-122.75,36.8,-121.75,37.8 would match any tweets containing the term Twitter (even non-geo tweets) OR coming from the San Francisco area.
Hope this helps.

Google GeoCoding Query

I am doing "Address Validation". My Address table has "Street Address", "City", "State", "Postal Code", "Country". I am using Google MAP API to validate my address.
I gave my address like
Street Address -- "kajhfkjdhfkjdsh"
City -- ksjfdlsjflsdjflk
State -- AP
PostalCode -- 500087
Country -- India
In this example only State, PostalCode, Country are valid and the remaining fields are invalid. But when I use the Google Map's API its saying its a valid address. But the street address and city are invalid.
So as per my observation the address validation is done only based on 3 fields those are (State, Postal Code, Country). So How can I validate Street and city along with the remaining fields with GOOGLE MAPS API?
Or is there any way/other (API) to validate all the fields in my address table.
Can anyone help me on this. I am stuck over here.
When trying this address with the google geocoding service http://maps.googleapis.com/maps/api/geocode/xml?sensor=false&address=kajhfkjdhfkjdsh,ksjfdlsjflsdjflk,AP,500087,India I see the result is of type postal_code and partial_match is set to true.
Trying real address I get the result type as street_address and the partial_match flag is missing.
I suggest you make some tests and check the content of the service result. This is a geocoding service, so it aims to give you a location to point your map to, not to validate addresses.

Getting stock symbol from company name

I have a company name and i want to get the stock symbol of that company and all the information related to it. I have tried using yahoo call back Stock ticker symbol lookup API but for some reason it returns a http 400 bad request. Could someone please tell me how i would go about getting the symbol for that stock so that i can query yahoo and get all the data. Also is it possible to just use this company name to get all the stock related data.
request i sent-"http://d.yimg.com/autoc.finance.yahoo.com/autoc?"+symbol+"=yahoo&callback=YAHOO.Finance.SymbolSuggest.ssCallback" where symbol=Thomas Scott
Your query is malformed. Try:
http://d.yimg.com/autoc.finance.yahoo.com/autoc?query=Thomas%20Scott&callback=YAHOO.Finance.SymbolSuggest.ssCallback

Categories

Resources