moocdev / osmdroid

Automatically exported from code.google.com/p/osmdroid
0 stars 0 forks source link

misleading documentation #287

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1.  create a GeoPoint with coordinates some set of coordinates (OUTSIDE OF YOUR 
CURRENT MAPS VIEW, something like 15.0, 135.0) and an empty Point
2.  call projection.toPixels (createdGeoPoint, createdEmptyPoint);
3. call projection.fromPixels (createdEmptyPoint.x, createdEmptyPoint.y) and 
compare the lat lon to createdGeoPoin

What is the expected output? What do you see instead?
expect the two lat lon's to be the same, the second lat lon seems to be based 
on my current screenrect and very different

What version of the product are you using? On what operating system?
3.0.5 jar

Please provide any additional information below.
The docs say that toPixels goes from geopoint to screen coordinates, and that 
fromPixels goes from screen coordinates to geopoint.  It seems then that you 
should be able to go straight from a geopoint to pixels and back and end up 
with the same point.  

I think two things would help: the current function fromPixels should have the 
name changed and the docs changed to more accurately describe what it does (not 
completely sure what that is though so i can't help) and then create a second 
function called fromPixels that operates independently of the screenrect.

Original issue reported on code.google.com by jpetti...@gmail.com on 22 Dec 2011 at 10:09

GoogleCodeExporter commented 8 years ago
I don't see a problem in fromPixels but rather in toPixels. Even when calling 
toPixels() of the mapcenter, the Result is very odd.

Try:
mapView.getProjection().toPixels(mapView.getMapCenter(), out)

Expected:
out should point to mapView.height/2, mapView.width/2

Actual Result:
out points to -18944, -6912

Original comment by tobias.n...@gmail.com on 7 Feb 2012 at 2:21

GoogleCodeExporter commented 8 years ago
      mMapView.getOverlays().add( new Overlay(this)
      {

         @Override
         protected void draw(Canvas arg0, MapView map, boolean arg2)
         {
            Projection projecton = map.getProjection();
            IGeoPoint gepoint = map.getMapCenter();
            Point point = projecton.toPixels(gepoint, null);
            Log.d(TAG, "Found center ("+gepoint.getLatitudeE6()+","+gepoint.getLongitudeE6()+") matching screen point ("+point.x+","+point.y+") ");
         }
      } );

The osmdroid projection only returns nonsense:
05-13 21:23:57.328: D/OsmMap(24173): Found center (48875554,5899658) matching 
screen point (4296,-40908) 

Original comment by rcgr...@gmail.com on 13 May 2012 at 7:25

GoogleCodeExporter commented 8 years ago

Original comment by kurtzm...@gmail.com on 10 Dec 2013 at 9:42

GoogleCodeExporter commented 8 years ago
Fixed in Github.

Original comment by kurtzm...@gmail.com on 16 Apr 2014 at 10:29