Guest User

Untitled

a guest
Apr 22nd, 2018
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  override public function getTexture(point:SphericalCoordinates, width:Number,
  2.                 height:Number):BitmapData {
  3.             /*
  4.                trace("______________тест________________________");
  5.            
  6.                getXForCoords(-imagesInfo.origin.longitude);//0
  7.                getXForCoords(imagesInfo.origin.longitude);//0
  8.                getXForCoords(1);//0
  9.                getXForCoords(4);//1
  10.                getXForCoords(imagesInfo.origin.longitude + 0.1);//0
  11.                getXForCoords(-imagesInfo.origin.longitude - 0.1);//1
  12.                trace("__________________________________________");
  13.              */
  14.             var uvPoint:Point = projection.sphericalToUv(point, imagesInfo.span,
  15.                     imagesInfo.origin);
  16.            
  17.             var maxSize:Size = imagesInfo.zoom.currentSize;
  18.             var col:Number = maxSize.width / imagesInfo.tilesSize.width;
  19.             var row:Number = maxSize.height / imagesInfo.tilesSize.height;
  20.            
  21.             trace("Sperical tile.longitude:",                point.longitude);
  22.             trace("imagesInfo.origin.longitude:",            imagesInfo.origin.longitude);
  23.             trace("imagesInfo.currentAngularSize.width:",    imagesInfo.currentAngularSize.width);
  24.            
  25.             var x:int = getXForCoords(point.longitude);
  26.             var y:int = (uvPoint.y - height / 4) * row;
  27.             var z:uint = imagesInfo.zoom.currentLevel;
  28.            
  29.             var tileUrl:String = getHashKeyByXyz(x,y,z);
  30.            
  31.             trace("x = ",   x);
  32.            
  33.             var loader:TileLoader = _loadersMap[tileUrl];
  34.             if(loader){
  35.                
  36.                 trace("Server tile.longitude",          loader.sphericalCoordinates.longitude);
  37.                
  38.                 var bitmap:Bitmap = Bitmap(loader.content);
  39.                 if (bitmap) {
  40.                     // обрезаем как надо
  41.                     // TODO - кэширование!!!!
  42.                     var sourceBitmapData:BitmapData = bitmap.bitmapData;
  43.                     // исходим из того что получаемый битмап лежит внутри исходного.
  44.                     // TODO: сделать объединение нескольких битмапов.
  45.                     var width0:uint = (width / loader.angularSize.width) * sourceBitmapData.width;
  46.                     var height0:uint = (height / loader.angularSize.height) * sourceBitmapData.height;
  47.                    
  48.                     var dLongitude:Number = AngleUtil.normRadiansTo2PI(point.longitude)
  49.                             - loader.sphericalCoordinates.longitude;
  50.                     trace("dLongitude",dLongitude);
  51.                    
  52.                     var dLatitude:Number = loader.sphericalCoordinates.latitude - point.latitude;
  53.                     var x0:int =  dLongitude * (sourceBitmapData.width / loader.angularSize.width);
  54.                     //x0 = x0%sourceBitmapData.width;
  55.                     var y0:int = dLatitude * (sourceBitmapData.height / loader.angularSize.height);
  56.                    
  57.                     var sourceRect:Rectangle = new Rectangle(x0, y0, width0, height0);
  58.                     var tileBitmapData:BitmapData = new BitmapData(width0, height0);
  59.                     tileBitmapData.copyPixels(sourceBitmapData, sourceRect, _zeroPoint);
  60.                    
  61.                     trace("sourceRect",sourceRect);
  62.                    
  63.                     return tileBitmapData;
  64.                 }
  65.             }
  66.             else {
  67.                 loadNewTile(tileUrl, point.clone() as SphericalCoordinates, width, height);
  68.             }
  69.             return emptyBitmapData;
  70.         }
  71.        
  72.         private function getXForCoords(longitude:Number):int {
  73.             var x:Number = (longitude +0.01 + imagesInfo.origin.longitude)
  74.                     /imagesInfo.currentAngularSize.width;
  75.             var maxSize:Size = imagesInfo.zoom.currentSize;
  76.             var col:Number = maxSize.width / imagesInfo.tilesSize.width;
  77.             var row:Number = maxSize.height / imagesInfo.tilesSize.height;
  78.             if (x < 0 && int(x)== 0)
  79.                 x = (col - 1);
  80.             /*trace("(",longitude," + ",imagesInfo.origin.longitude,")/",
  81.                imagesInfo.currentAngularSize.width);*/
  82.             trace("TiledTextureProvider.getXForCoords(",longitude,") = ", int(x));
  83.             return int(x);
  84.         }
Add Comment
Please, Sign In to add comment