×

Discussion Board

Results 1 to 13 of 13
  1. #1
    Registered User
    Join Date
    Oct 2013
    Posts
    23

    reverse geocoding j2me

    Hello,

    I want to reverse geocoding with TinyGeocode
    I see the source code :http://mobilepit.com/tag/source-code
    but I don't know how p how can I use this source code???. and is it need
    emulator to run this project. because you say that " the code source has been tested on Nokia E71 and 6210 Navigator"

    when I test the sourcecode I have the folowing error:
    this public service is disconnection


    Thank you in advance.


    Best regards.

  2. #2
    Super Contributor
    Join Date
    Mar 2003
    Location
    Finland
    Posts
    9,561

    Re: reverse geocoding j2me

    The code is linking to a specific server, which is responding with: "This public service has been discontinued. Please visit https://github.com/nateritter/TinyGeocoder to run your own geocoder. Thank you, and we apologize for the inconvenience."

    In other words, the server/service the code depends on is apparently no longer available, and you need to create your own server for your mobile app to talk to (based on the code on GIThub that the response points to).

  3. #3
    Regular Contributor
    Join Date
    Aug 2011
    Location
    Berlin
    Posts
    288

    Re: reverse geocoding j2me

    If you are looking for a reverse geocoder with Java ME you could look at using the HERE Maps API for Java ME, which provides a convenient wrapper around the RESTful Geocoder API, to get started all you need is an evaluation key available here.

    If you just need reverse geocoding, the HERE Maps API for Java ME shouldn't add too much size to your app assuming you obfuscate your JAR. Of course as the name implies, the service does maps as well. This thread helps to describe which sort of mapping API would best suit your use case, so you could use reverse-geocoding and static maps for instance.

  4. #4
    Registered User
    Join Date
    Oct 2013
    Posts
    23

    Re: reverse geocoding j2me

    thank you so much for replies.
    I need the reverse geocoding because I'm interested in mobile development and i need the logical info such as city in my application. please tell me can I use the LBS api to do reverse geocoding. if yes, please tell me how.
    Best regards

  5. #5
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: reverse geocoding j2me

    You can use code in your project - http://mobilepit.com/tag/source-code


    It uses - http://tinygeocoder.com/

    service to get you the city name.
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

  6. #6
    Super Contributor
    Join Date
    Mar 2003
    Location
    Finland
    Posts
    9,561

    Re: reverse geocoding j2me

    Quote Originally Posted by im2amit View Post
    You can use code in your project - http://mobilepit.com/tag/source-code


    It uses - http://tinygeocoder.com/

    service to get you the city name.
    That particular piece of code was already discussed in the original post (and my reply) above.

  7. #7
    Registered User
    Join Date
    Oct 2013
    Posts
    23

    Re: reverse geocoding j2me

    hi,
    I download the software from https://github.com/nateritter/TinyGeocoder.
    I try to install it. but unfortunately I don't know how to install ant run it.

  8. #8
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: reverse geocoding j2me

    Quote Originally Posted by hsoraya View Post
    hi,
    I download the software from https://github.com/nateritter/TinyGeocoder.
    I try to install it. but unfortunately I don't know how to install ant run it.
    Leave it - Here is better and simple solution for you, you can just make a HTTP request on the below mentioned URL from your app - passing the lat/long to it for which you wish to get the city name and it will return you the result in XML as below - I tried it for Noida, India as below.

    Request
    http://ws.geonames.org/findNearbyPla...8.57&lng=77.32

    Response
    <geonames>
    <geoname>
    <toponymName>Noida</toponymName>
    <name>Noida</name>
    <lat>28.58</lat>
    <lng>77.33</lng>
    <geonameId>7279746</geonameId>
    <countryCode>IN</countryCode>
    <countryName>India</countryName>
    <fcl>P</fcl>
    <fcode>PPL</fcode>
    <distance>1.47833</distance>
    </geoname>
    </geonames>
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

  9. #9
    Registered User
    Join Date
    Oct 2013
    Posts
    23

    Re: reverse geocoding j2me

    thank you so much for the reply.
    please tell me im2amit how can I use that in my j2me midlet project because my midlet is connect to servlet

  10. #10
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: reverse geocoding j2me

    You need to create a new HTTP network connection in a separate thread in your midlet - pass the required lat/long to the server (http://ws.geonames.org/findNearbyPla...8.57&lng=77.32), fetch the response from it - it will be XML, now you need to parse the SMS response to fetch the name node from it using any XML parser.

    Sample code this URL will help you - http://developer.nokia.com/Community...TPS_in_Java_ME

    For help on XML response parseing you can refer to - http://j2mesamples.blogspot.in/2009/...g-in-j2me.html
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

  11. #11
    Registered User
    Join Date
    Oct 2013
    Posts
    23

    Re: reverse geocoding j2me

    Hi,
    thank you im2amit.
    I try to use (http://ws.geonames.org/findNearbyPla...8.57&lng=77.32), it run. but unfortunately, when add the source code in my application. my app does not work correctly.

    the class that the reverse geocode is:
    /*
    * To change this template, choose Tools | Templates
    * and open the template in the editor.
    */

    package application;
    import javax.microedition.io.*;
    import java.io.*;

    /**
    *
    * @author MED
    */
    public class ReverseGeocoder
    {
    public ReverseGeocoder() {
    }
    public String getlocationname()
    {
    HttpConnection conn=null;
    InputStream is=null;
    String sb,g="",name="",test="", city = null,sUrl=null;
    //String sUrl = "http://tinygeocoder.com/create-api.php?g="+""+lat+","+""+lon;
    sUrl = "http://ws.geonames.org/findNearbyPlaceName?lat=6&lng=100";
    // sUrl = "http://ws.geonames.org/findNearbyPlaceName?lat="+""+lat+"&lng="+""+lon;
    /* sUrl = "http://ws.geonames.org/findNearbyPlaceName?lat=";
    sUrl=sUrl+Double.toString(lat);
    sUrl=sUrl+"&lng=";
    sUrl=sUrl+Double.toString(lon);
    */

    try
    {
    conn = (HttpConnection) Connector.open(sUrl,Connector.READ);
    if (conn.getResponseCode() == HttpConnection.HTTP_OK)
    {
    is = conn.openInputStream();
    byte buf[] = new byte[103];
    int total =0,k=0;
    while (total < 103)
    {
    int count = is.read(buf,total,103-total);
    if (count<0)
    {
    break;
    }
    total += count;
    g = new String(buf,0,total);

    //name=g.substring(0,10);
    if(g.indexOf("name")>=0)
    {
    k=total;
    total=1500;
    }


    }
    sb = new String(buf,0,k);//total);
    if (sb.length() < 10)//sb.length() < 10)
    {
    showAlert("Connection error, please try again");
    is.close();
    conn.close();
    }
    // StringItem sili = new StringItem("","");
    // sili.setText(sb);
    // mainform.append(sb);
    // sili.setText(sb);
    if(g.indexOf(name)>=0)//sb.indexOf(name)>=0)
    {
    city=sb.substring(89);
    // mainform.append(city);
    }
    // else mainform.append("sbnnnnnnnnnnnn");

    }
    else
    if (conn.getResponseCode() == HttpConnection.HTTP_NOT_FOUND)
    {
    showAlert("URL not found");
    }
    else
    {
    showAlert("Server busy or unavailable. Please try again later");
    }
    }
    catch (SecurityException sex)
    {
    showAlert("Connection failed. You need to authorize this application to access network");
    }
    catch (IOException ioex)
    {
    showAlert("Connection failed. Please try again later.");
    }
    catch (Exception e)
    {
    showAlert(e.toString());
    e.printStackTrace();
    // display.setCurrent(mainform);
    }
    finally {
    try {

    if (is != null) {
    is.close();
    }

    if (conn != null) {
    conn.close();
    }
    } catch (IOException ioexception) {}
    is =null;
    conn =null;
    // display.setCurrent(mainform);
    }




    return city;
    }
    public void showAlert(String message) {
    // Alert alert = new Alert("Alert",message,null,AlertType.WARNING);
    // display.setCurrent(alert,form);
    }

    }
    my application is midlet that connect to servlet. moreover

    the folowing code of my application is run corretly: but i need to send the string location to servlet. when I send it is dont run correctly
    reversegeocoder = new ReverseGeocoder();
    String location =reversegeocoder.getlocationname();
    //score=score+location;

  12. #12
    Registered User
    Join Date
    Oct 2013
    Posts
    23

    Re: reverse geocoding j2me

    hello,
    please tell me how can I do new HTTP network connection in a separate thread in your midlet .
    BR

  13. #13
    Nokia Developer Champion
    Join Date
    Feb 2009
    Location
    Noida, India
    Posts
    3,087

    Re: reverse geocoding j2me

    Refer to the example - http://developer.nokia.com/Community...TPS_in_Java_ME

    It shows, how to connect to a server to fetch data, how to parse it to get the required info and in last how to send this data to another server (servlet if needed).
    thanks,
    ~Amitabh
    (Champion of the Month -Aug'13)
    Follow me on my blog for Innovative Mobile Apps

Similar Threads

  1. reverse geocoding+j2me
    By shwetadseema in forum Mobile Java General
    Replies: 6
    Last Post: 2011-04-25, 14:12
  2. reverse geocoding API
    By spoorthy in forum Qt
    Replies: 2
    Last Post: 2011-03-11, 09:16
  3. Reverse Geocoding in Java
    By harriskorn in forum Mobile Java General
    Replies: 6
    Last Post: 2011-02-27, 17:02
  4. Geocoding and reverse geocoding in Qt Mobility
    By QtQueries in forum [Archived] Qt Mobility Project
    Replies: 5
    Last Post: 2011-02-15, 14:26

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
×