def deserialize(self): slicedTile = SlicedTile() isAckDate = self._boolSerializer.deserialize() if isAckDate > 0: slicedTile._aquisitionDate = self._stringSerializer.deserialize() slicedTile._band = self._intSerializer.deserialize() slicedTile._leftUpperLon = self._doubleSerializer.deserialize() slicedTile._leftUpperLat = self._doubleSerializer.deserialize() slicedTile._rightLowerLon = self._doubleSerializer.deserialize() slicedTile._rightLowerLat = self._doubleSerializer.deserialize() slicedTile._height = self._intSerializer.deserialize() slicedTile._width = self._intSerializer.deserialize() hasContent = self._boolSerializer.deserialize() if hasContent > 0: slicedTile._content = self._bytesSerializer.deserialize() row = self._intSerializer.deserialize() col = self._intSerializer.deserialize() slicedTile._positionInTile = row, col return slicedTile
def flat_map(self, value, collector): originalTileHeight = value._height originalTileWidth = value._width slicedTilesPerRow = originalTileWidth / self.slicedTileWidth slicedTilesPerCol = originalTileHeight / self.slicedTileHeight originalTileS16Tile = value._content #print("The type of originalS16: " + type(originalTileS16Tile).__name__) for row in xrange (0, slicedTilesPerRow): for col in xrange (0, slicedTilesPerCol): slicedTileLeftUpperCoordLon = floor(value._leftUpperLon - value._rightLowerLon) / slicedTilesPerCol * row slicedTileLeftUpperCoordLat = floor(value._leftUpperLat - value._rightLowerLat) / slicedTilesPerRow * col slicedTileRightLowerCoordLon = floor((value._leftUpperLon - value._rightLowerLon) / slicedTilesPerCol * (row + 1)) slicedTileRightLowerCoordLat = floor((value._leftUpperLat - value._rightLowerLat) / slicedTilesPerRow * (col + 1)) band = value._band #Typo because of legacy issues aquisitionDate = value._aquisitionDate slicedTileS16Tile = bytearray() for slicedTileRow in xrange (0, self.slicedTileHeight): startIndex = col*self.slicedTileWidth + slicedTileRow*self.slicedTileWidth*slicedTilesPerRow + row*self.slicedTileWidth*self.slicedTileHeight*slicedTilesPerRow endIndex = col*self.slicedTileWidth + slicedTileRow*self.slicedTileWidth*slicedTilesPerRow + row*self.slicedTileWidth*self.slicedTileHeight*slicedTilesPerRow + self.slicedTileWidth tempSlicedTileS16Tile = originalTileS16Tile[startIndex * 2: endIndex * 2] #print ("Startindex and endIndex: ", startIndex,endIndex ) #print ("The tempSlicedTile: ",tempSlicedTileS16Tile) slicedTileS16Tile.extend(tempSlicedTileS16Tile) #print("The type of newS16: " + type(slicedTileS16Tile).__name__) slicedTile = SlicedTile() slicedTile._content = slicedTileS16Tile #slicedTile._content = originalTileS16Tile slicedTile._leftUpperLat = slicedTileLeftUpperCoordLat slicedTile._leftUpperLon = slicedTileLeftUpperCoordLon slicedTile._rightLowerLat = slicedTileRightLowerCoordLat slicedTile._rightLowerLon = slicedTileRightLowerCoordLon slicedTile._width = self.slicedTileWidth slicedTile._height = self.slicedTileHeight slicedTile._band = band slicedTile._aquisitionDate = aquisitionDate slicedTile._positionInTile = (row, col) #print ("The aqu Date: " + str(slicedTile._aquisitionDate)) collector.collect(slicedTile) #self.allDatesList.append(value._aquisitionDate) print("The flatmap is over")