most near place in android
<p>My goal is searching the most near place to my current position.</p>

<p>I have an XML file contents the different places with her longitude and latutude cordinates.</p>

<p>I created a code to determine my current position</p>

<pre><code>    package com.geoo;

import android.app.Activity;
import android.content.Context;
import android.location.Location;
import android.location.LocationListener;
import android.location.LocationManager;
import android.os.Bundle;
import android.widget.Toast;

public class localisation extends ActivityBase{

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState){

super.onCreate(savedInstanceState);
setContentView(R.layout.localisation);

/* Use the LocationManager class to obtain GPS locations */

LocationManager mlocManager = (LocationManager)getSystemService(Context.LOCATION_SERVICE);

LocationListener mlocListener = new MyLocationListener();

mlocManager.requestLocationUpdates( LocationManager.GPS_PROVIDER, 0, 0, mlocListener);

}

/* Class My Location Listener */

public class MyLocationListener implements LocationListener

{

@Override

public void onLocationChanged(Location loc)

{

loc.getLatitude();

loc.getLongitude();

String Text = "My current location is: " + "Latitud = " + loc.getLatitude()+  "Longitud = " + loc.getLongitude();
Toast.makeText( getApplicationContext(),Text, Toast.LENGTH_SHORT).show();
}

@Override

public void onProviderDisabled(String provider)
{
Toast.makeText( getApplicationContext(),"Gps Disabled",Toast.LENGTH_SHORT ).show();
}

@Override

public void onProviderEnabled(String provider)
{
Toast.makeText( getApplicationContext(),"Gps Enabled",Toast.LENGTH_SHORT).show();
}

@Override

public void onStatusChanged(String provider, int status, Bundle extras)

{
}
}/* End of Class MyLocationListener */

}/* End of UseGps Activity */
</code></pre>

<p>I created also a Parser XML and this is the code</p>

<pre><code>package xmlparse;


import java.io.IOException;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;

import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

public class QueryXML {
    public void query() throws ParserConfigurationException, SAXException,
            IOException, XPathExpressionException {
        // Standard of reading a XML file
        DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
        factory.setNamespaceAware(true);
        DocumentBuilder builder;
        Document doc = null;
        XPathExpression expr = null;
        builder = factory.newDocumentBuilder();
        doc = builder.parse("a.xml");  //C:\\Users\\aymen\\Desktop\\

        // Create a XPathFactory
        XPathFactory xFactory = XPathFactory.newInstance();

        // Create a XPath object
        XPath xpath = xFactory.newXPath();

        // Compile the XPath expression
        expr = xpath.compile("/postes/poste[gouvernourat='Tunis']/longitude/text()");
        // Run the query and get a nodeset
        Object result = expr.evaluate(doc, XPathConstants.NODESET);

        // Cast the result to a DOM NodeList
        NodeList nodes = (NodeList) result;
        for (int i=0; i&lt;nodes.getLength();i++){
            System.out.println(nodes.item(i).getNodeValue());
        }
    }

    public static void main(String[] args) throws XPathExpressionException, ParserConfigurationException, SAXException, IOException {
        QueryXML process = new QueryXML();
        process.query();
    }
}
</code></pre>

<p>Now how can i determine the most near place proportionnaly to my current location?</p>

<p>Thank you in advance</p>
