Posts mit dem Label Google werden angezeigt. Alle Posts anzeigen
Posts mit dem Label Google werden angezeigt. Alle Posts anzeigen

Sonntag, 30. Mai 2010

Geospatial JDO queries on the Google AppEngine (+ GWT)

From time to time one might feel the urgent need to execute geospatial queries on the Google AppEngine. Thinking in common SQL this is pretty easy, just a combined WHERE clause:

SELECT * FROM t_spatialdata
WHERE latitude >= south AND latitude <= north AND longitude >= west AND longitude <= east

Unfortunately something like this is not possible, when using AppEngine, as you can only filter by one argument (i.e. only by latitude). I think the reason for this is that AppEngine internally sorts the table and then 'cuts' away what doesn't match the filter.

So this problem can basically be solved, by using a algorithm called Geohash, which unfortunately didn't want to return proper results, at least not the implementations I found. (The 'official' implementation uses the BitSet-Class which is not present when using AppEngine/GWT)

The solution I went for is the "javageomodel"-project which follows (afaik) a similar algorithm but worked. http://code.google.com/p/javageomodel/

The problem you will face, when trying to use this in your AppEngine project is that it will be missing (just at runtime!) two classes from the Apache Commons project: StringUtils and Validator. At least the latter one is over 1MByte in size. So I decided to replace the Validator lines with standard "assert"-calls, but adding the jars probably would have worked too.

For your convenience I uploaded the final jar that works fine:
http://rapidshare.com/files/393375528/libjavageomodel.jar.html
A how to use this for actual queries is located here:
http://code.google.com/p/javageomodel/source/browse/trunk/geocell/src/test/java/com/beoui/utils/HowToUseGeocell.java

Donnerstag, 20. Mai 2010

HttpServlet doGet / doPost throwing unexpected Exception

Ever wondered why your HttpServlet on Google AppEngine didn't work, even if the code looks sooooo right?
You might have (accidentally) called super.doPost(...,...); or super.doGet(...,...); which calls the default implementation of HttpServlet, which throws an Exception!
package org.crazy.servlets;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

public class CrazyServlet extends HttpServlet {

 @Override
 protected void doGet(final HttpServletRequest pReq, final HttpServletResponse pResp) throws ServletException, IOException {
  this.doPost(pReq, pResp);
 }

 @Override
 protected void doPost(final HttpServletRequest pReq, final HttpServletResponse pResp) throws ServletException, IOException {
   super.doPost(pReq, pResp); // <-- DON'T !!! Just delete this line
  // Insert actual work here...
 }
}
Took me quite some to figure this out =D

Sonntag, 7. Februar 2010

Mobile World Congress 2010 - Barcelona

Hi guys,

I have good news (for me =P)!
Some days ago Google opened the Sign-Up for their Android Developer Labs on the Mobile World Congress. I decided to apply for that technical session amongst other Android developers, knowing I would never win anything. The even better thing about this was that 'winners' would also receive a Complimentary MWC Pass worth $700 !

Et voilà - a few days later I had the invitation in my inbox!

Be sure I'll take some great pictures of never before seen gadgets, talks and people with my new Canon EOS 450D!

Best Regards,
Nicolas