Zoadian

Untitled

Apr 13th, 2012
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.71 KB | None | 0 0
  1. TileCoordinate p1_t = GeoCoordToTileCoord(p1_lat, p1_long, zoom);
  2. TileCoordinate p2_t = GeoCoordToTileCoord(p2_lat, p2_long, zoom);
  3.  
  4. CPoint p1;
  5. p1.x = 256*p1_t.intpartX + p1_t.fractpartX;
  6. p1.y = 256*p1_t.intpartY + p1_t.fractpartY;
  7.  
  8. CPoint p2;
  9. p2.x = 256*p2_t.intpartX + p2_t.fractpartX;
  10. p2.y = 256*p2_t.intpartY + p2_t.fractpartY;
  11.  
  12. CPoint pIntersect;
  13.  
  14. for(double i  = p1.x; i < p2.x ; ++i)
  15. {
  16.     if(i%256 == 0)
  17.     {
  18.         double dy = p2.y-p1.y;
  19.         double p = i/(p2.x-p1.x);      
  20.         pIntersect.y = dy*p;
  21.     }
  22. }
  23. for(double i  = p1.y; i < p2.y ; ++i)
  24. {
  25.     if(i%256 == 0)
  26.     {
  27.         double dx = p2.x-p1.x;
  28.         double p = i/(p2.y-p1.y);      
  29.         pIntersect.x = dx*p;
  30.     }
  31. }
  32.  
  33. //retransform px part to tile coord and add pIntersect
Advertisement
Add Comment
Please, Sign In to add comment