The App Engine Search API has a GeoPoint field. Is it possible to use it to do radius search? As in, given a GeoPoint, find all documents that fall within a certain radius.
As of right now it looks like GeoSpecial Query is by invitation only, so I am seeking a simple alternative that is easy for me to understand.
Also, if somehow this matters, I am using objectify and this answer is too complicated for me to understand how to implement it.
For radius search, use proximitySearch instead of bestBboxSearchCells (using in your reference url):
GeocellManager.proximitySearch(Point center, int maxResults, double maxDistance //...
Use can see in this link for details of methods:
https://github.com/theganyo/javageomodel/blob/ce43c507ff671eb6f0998f7c7d78fd0c3877dbe7/geocell/src/main/java/com/beoui/geocell/GeocellManager.java
And the example code, it is very straightforward:
https://github.com/theganyo/javageomodel/blob/master/geocell/src/test/java/com/beoui/utils/HowToUseGeocell.java
As noted by Alex Martelli, the query string "distance(store_location, geopoint(-33.857, 151.215)) < 45000" would effectively yield the results you seek replacing geopoint() with the location you're looking near and replacing 45000 with the distance within which you'd like the results to be.
This query string is runtime agnostic and can therefore be used in the same way for both Python and Java runtimes.
If you've gone with a different approach, product or solution, feel free to post it here.
Related
I have a gps coordinate, I wish to get a list of adresses inside it's certain radius. From these adresses I wish to select the ones that are companies and contain specific sector name. (clothing, finance, metallurgy, etc..), I thought the returned api object may contain the necessary information to make the distinction. Is there a free api that has the necessary functions to bring me closer to my goal ? (like google maps, google places, yahoo placefinder, and similar applications.)
Note: I use the MVEL language, I guess it has access to some Java functions so you can consider me writing Java, but any information considering the MVEL language is also appreciated.
Note2: Radius is not an essential requisite, it would be enough if I found the adresses in a certain district. The classification however, is necessary.
I think you can take a look into :
GoogleMapServicesJava
Particulary into the Places API service :
Places API
Where you can query a search sort by radius, place type, etc...
Hope that will help !
I am working on a project in Android for my Signal Processing course. My aim is to find signal properties, such as periodicity, even/odd, causality etc, given a user-input function. Right now, I am stuck at trying to figure out how to programmatically calculate the periodicity of a given function. I know the basics behind periodicity: f(t+T) = f(t)
The only idea I have right now is to extensively calculate values for the function, and then check for repetition of values. I know the method is quite stupid, given the fact I don't know how many such values I need to calculate to determine if it is periodic or not.
I know this can be done easily in Matlab, but again very difficult to port Matlab to Java. Is there something I am missing? I have been searching a lot, but haven't found anything useful.
Thanks for any help, in advance!
If the function f is given as a symbolic expression, then the equation you stated can in some cases be solved symbolically. The amount of work required for this will depend on how your functions are described, what kinds of functions you allow, what libraries you use and so on.
If your only interaction with the function is evaluating it, i.e. if you treat the function description as a black box or obtain its values from some sensor, then your best bet would be a Fourier transformation of the data, to convert it from the time domain into frequency domain. In particularly, you probably want to choose your number of of samples to analyze as a power of two, and then use FFT to quickly obtain intensities for various frequencies.
I'm having a problem with Solr 3.4, I'm using it's spacial search functions like
Geodist, and Geofilt.
Everything seems ok and the results are return supposedly sorted by distance form a given center point.
However since Solr 3.4 lacks the ability to return function results in the data I had to calculate it manually (by PHP in this case).
I read the docs and the geodist should be a function that implements the haversine function of geo distance between 2 lat/lng points. I ported the function to PHP (easy!), and made sure that it give correct result.
The problem is: Solr calculate the distance in different formula that I couldn't find. So when I re-calculate the distance in PHP it results a inconsistent data distances (e.g. 132Mile instead of 83Mile), that's not a difference I can tolerate.
My Solution: I said OK it's handy to create a function comparison to see if I made a mistake in my port to the data, I dug into Solr code and extracted the literal implementation of havesine in org.apache.solr.search.function.distance.HaversineConstFunction, and the result was almost identical. and made this testing script (full source code and data).
My conclusion that Solr (or Lucene) does not use haversine as a geodist implemenation. But I don't know which equation.
UPDATE The bug was resolved. I think I went too far with my tests. The incorrect results occurred because of wrong parameter naming, I was using order (the one from SQL) instead of sort (Solr convention) to change the order of the results from the Solr web-service.
See the update, bug have been resolved. Thanks to #jarnbjo, and #TreyA for reminding me of a stupid issue. I should look to stupid mistakes in my code before debugging the libraries code in the future.
I am using the 'Twitter4j' library and I am just wondering if it is at all possible to return tweets within a location AND contain a certain keyword. I notice that on the official Twitter documentation it mentions this:
Bounding boxes are logical ORs. A locations parameter may be combined with track parameters, but note that all terms are logically ORd, so the query string 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.
Which is unfortunate as it is not what I need, it's returning way too many tweets. Any idea on how I could get around this or is there something I'm missing in the library that could allow me to do it?
Library javadoc: http://twitter4j.org/en/javadoc/twitter4j/FilterQuery.html#locations
At the moment I have my filter code like this
twitter.filter(new FilterQuery().locations(sydney).track(keywords));
and have also tried each on its own line:
twitter.filter(new FilterQuery().locations(sydney).track(keywords));
twitter.filter(new FilterQuery().track(keywords));
Unfortunately, you are reading the documents correctly. I don't know enough about twitter4j to say if there's a method contained somewhere that will handle this for you more easily, but you can always just use a simple string comparison to see if your search terms are included in the tweet.
Not an answer but a Simple workaround:
I know most of people don't have GPS enabled when they tweet and others would not like to share their location!
But they are still sharing their location!! Guess how? On their profiles! Their hometown, their country is mostly visible, which can give you an approximate location of where the tweet came from! You can query for the user's profile and thus his/her location using the Rest API
twitter.showUser(userScreenName).getLocation();
Search for all keywords, if the location you wan't doesn't match, simply discard! In this way, you can get more number of tweets atleast
I am developing a desktop application and I have two point (latitude, longitude). How can I get the distance between these two points? I have looked at the API and most of them are javascript or web based. I am not developing a web page. How can I do this in java?
I want a road distance, not a straight distance
If you've got the latitude and longitude, you can use the Haversine formula to calculate the distance between them - assuming you want "straight line" distance.
EDIT: Okay, now you've actually told us what you want, I suspect you need to use the Directions API. You'll need to make a web request to the appropriate URL with your parameters, specifying either XML or JSON output - which you'll then need to parse.
Note that "JSON" != "Javascript-based". Think of JSON as a data serialization format which just happens to be executable Javascript.
A quick Google gave me this: http://www.postalcodeworld.com/samples/distance.java.html Looks like this is a pretty good implementation of what you need using the Haversine Formula I think.
This Great Circle Distance code above is probaby OK for most apps. If you need great deal of precision, though, be aware that it may fail in some edge cases due to the earth not being a perfect sphere. In that case you're talking about more complicated algorithms.