Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Highlighted
Regular Contributor
Posts: 66
Registered: ‎08-28-2010
My Device: 9630

Latitude and longitude problem

Hi,

 

 i am develpoing GPS application and found one problem. i am looking to get help regarding the GPS latitude

and longitude.

 

 I am able to get the latitude and longitude. but i get the value with only 5 precsion as below.

 

newlng -88.13795 - and  - newlat 41.91769

 

the problem is that i want precesion value with minium 8 precesion. i am usign the cell site location.

 

i.e. i want precesion value with format  -88.137954585 - and  - newlat 41.9176978945.

 
can anyone suggest me so i can get the perfect latitude and longitude every time.

 

becaus as i get the latitude and longitude with small precesion i get the disatnce between two latitude and longitude always 0.0.

 

my code for getting latitude and longitude is as below.

 

 class GPSThread extends Thread
    {
    	public void run() 
        {
    
		    		try
		    		{
	                    blackBerryLocation = (BlackBerryLocation) blackBerryLocationProvider.getLocation(60);
	                    QualifiedCoordinates qualifiedCoordinates = blackBerryLocation.getQualifiedCoordinates();
	                    lat = qualifiedCoordinates.getLatitude();
	                    lng = qualifiedCoordinates.getLongitude();
	                    if(lat != 0.0 && lng !=0.0 && CommonInterface.writelocation)
		    		    {
		                    	CommonInterface.writelocation = false;                                  //outrange       //notify = false
			    				String l_point = String.valueOf(lat)+ "$" + String.valueOf(lng) + ":" + "false" + "&" + "false";
			    				System.out.println("l_point"+l_point);
			    				MainClass.debug("pairing latitude"+ l_point);
			    				MainClass.debug("paring device name"+ CommonInterface.doorDeviceName);
			    				CommonInterface.hashgpsmonitor = CommonInterface.loadhashTable(CommonInterface.gps_pointFile);
			    				if(CommonInterface.hashgpsmonitor == null)
			    					CommonInterface.hashgpsmonitor = new Hashtable();
			    				if(CommonInterface.hashgpsmonitor != null && CommonInterface.doorDeviceName != null && CommonInterface.hashgpsmonitor.containsKey(CommonInterface.doorDeviceName))
			    					CommonInterface.hashgpsmonitor.remove(CommonInterface.doorDeviceName);
			    				CommonInterface.hashgpsmonitor.put(CommonInterface.doorDeviceName,l_point);
			    				CommonInterface.writeHastTableTotextFile(CommonInterface.hashgpsmonitor, CommonInterface.gps_pointFile);
			    				gpsThread.interrupt();
			    				MainClass.debug("Thread cleared");
		    		    }
	                    if(lat == 0.0 && lng == 0.0 && CommonInterface.writelocation)
	                    {
	                    	CommonInterface.writelocation = false;
	                    	MainClass.debug("you get 0.0 and 0.0 location");
	                    }
	        		}
	        		catch (Exception e)
	        		{
	        			if(CommonInterface.writelocation)
	        			{
	        				CommonInterface.writelocation = false;
	        			}
	        			MainClass.debug("GEt not coordinates");
	    			}
	       	}
	        	
    }
    class myLocationListener implements LocationListener
    {
       
        public void providerStateChanged(LocationProvider provider, int newState)
        {
        	if(newState==LocationProvider.AVAILABLE)
        		MainClass.debug("provider available :");
          else
            {
            	OnlineInterface.createNotification("Region Monitoring is disabled due Location Service is Disabled.");
                provider.reset();
                provider.setLocationListener(null,-1,-1,-1);
                provider.setLocationListener(this,timerinterval,-1,-1);
            }
        }

		public void locationUpdated(LocationProvider arg0, Location location)
		{
			try
			{
				//if(location != null && location.isValid())
				MainClass.debug("Location update found");
				if(location != null)
				{
					newlat = location.getQualifiedCoordinates().getLatitude();
					newlng = location.getQualifiedCoordinates().getLongitude();
					MainClass.debug("new Location found");
					updateUIDisaply(true);
				}
		
           }
			catch(Exception e)
			{
				MainClass.debug("E stackStrace location not updated"+ e.getMessage());
			}
		}
    }

 

 Looking for immediate help...

 

Regards,

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Latitude and longitude problem

Before you start trying to use these values, you should be aware that these values are guesses, they are not necessarily accurate.  Their accurateness will depend on the method that was used to obtain them and in the case of GPS, the number of satellites used to obtain the values.  You need to look at the QualifiedCoordinates getHorizontalAccuracy() (and possibly getVerticalAccuracy()).  This will give you a standard deviation from which you can calculate a probability curve for your location.  For example, in my area, the Cell site location gives me a horizontal accuracy value of 500 meters, which basically means that the estimate suggests that I am located with 99% certainty, within 1.5 kms of the location it has given me.  Which is true - as there is only one mast in this area the location is not accurate, in fact the location it invariably suggests for me, is about 1 km away. 

 

The other thing to be aware of is that these values will change, especially GPS values, even if you don't move.  This is because GPS locations are impacted by a number of external factors including the weather, which varies from second to second. 

 

So attempting to track with the accurateness you want is difficult. 

 

But back to your point.  If you want more precession, you are going to have to use GPS tracking.  I don't think any other method will give your location to the accurateness you want.   Event then you should check the accurateness of the location before trying to read too much into it.

Regular Contributor
Posts: 66
Registered: ‎08-28-2010
My Device: 9630

Re: Latitude and longitude problem

Hi,

Peter

 

 i am not more aware of the of how the location are calcualated based on the curve as you have said below.

 

"For example, in my area, the Cell site location gives me a horizontal accuracy value of 500 meters, which basically means that the estimate suggests that I am located with 99% certainty, within 1.5 kms of the location it has given me.  Which is true - as there is only one mast in this area the location is not accurate, in fact the location it invariably suggests for me, is about 1 km away. "

 

I only know to use the code of Blackerry and retrive the latitude and longitude. as i get latitude and longitude

with small precesion can u suggest me code so i can get latitude and longitude with more precesion.

because losing of precesion happen sometimes while getting latitude and longitude. if any method that enforce

to have bigger precesion.

 

Regards,

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: Latitude and longitude problem

I think you are missing the point I was trying to make.

 

When you get a location, the Location indicates a point.  But this point is a guess.  It can be a pretty accurate guess, if you are standing in the middle of a Field with clear access to 12 satellites and you are using GPS.  But even then, it is a guess.  To indicate how accurate the system thinks the guess is, it will give you an accurateness figure. 

 

To give you an example of how this works, imagine you have a map, and the coordinates you have got, give you a point on that map.  Then you look at the accurateness figure.  Multiply this figure by 3, and then use that as a distance in meters.  Now draw a circle around the point on the map, with a radius of the distance you have calculated from the accurateness figures.  Statistically, the real position will, 99% of the time, be inside that circle.  Anywhere inside that circle.   And 1% of the time it could be outside the circle. 

 

Got that?

 

"I only know to use the code of BlackBerry and retrieve the latitude and longitude".  You are missing the fact that what you are actually getting is a QualifiedCoordinate - you have glossed over the extra bits of information that come with this object and are only using the latitude and longitude.  If that was all that was important, why does the BB give you a QualifiedCoordinate and not just a Coordinate?  I think that you need to understand the figures that you are getting and what they actually mean.  

 

"i get latitude and longitude with small precision"

Technically this is not correct.  If I give you a double and when you print that value out you get the value "1.0", was the actual value 1.0, or 1.00, or 1.000, or 1.0000.  You can't tell.  So when you are given a value, you should also be given some idea of how accurate the value is.  Which is what the QualifiedCoordinate actually does. 

 

"if any method that enforce to have bigger precision"

I will reword this question more correctly to ask "how can I get a value with more accuracy".  Using Cell Site, I would say it is impossible.  Cell Site is just a guess based on triangulation between masts and as I understand it, it tries to factor in things like the strength of your signal.  It is not a great guess because there are many factors that effect this.  And you can tell how accurate it is by getting the accurateness figures.   

 

If you want a really accurate location, use GPS.  But you will still have to check the accuracy values that are supplied to you.