guzmand

Problems Downloading Tiles Cache

Discussion created by guzmand on May 14, 2014
Latest reply on May 19, 2014 by JTrieu-esristaff
Hi,

I had a look at the example "Download Cache Tile (Beta)" and the program never starts the download of the cache tile, no signals were emitted from the tilecachetask and the progress bar wasn't displayed.

Trying to check this behavior, I did a small program based on this example and I got the same result, the TileCacheTask did not download the tiles. Then I modified the initialization of the TileCacheTask, adding an "userCredentials" with the info of my ESRI Global Account  and later the info of my Developer Account, in both cases the TileCacheTask emitted the signal "tileCacheError" showing an "Invalid token" error and later the TileCacheStatus signal. How can I solve this problem?

Please find below my snippet of code.

Best regards,

David

// adding the tileServiceLayer
m_tiledServiceLayer = EsriRuntimeQt::ArcGISTiledMapServiceLayer("http://services.arcgisonline.com/ArcGIS/rest/services/World_Street_Map/MapServer");
m_map.addLayer(m_tiledServiceLayer);

// tileCacheTask
m_serviceUrl    = "http://tiledbasemaps.arcgis.com/arcgis/rest/services/World_Street_Map/MapServer";
m_usercredentials.setUserAccount("*****", "***");
m_tileCacheTask = EsriRuntimeQt::TileCacheTask(m_serviceUrl, m_usercredentials); 


// Add a rectangle
QPoint pointo;
mapPoint= m_map.toMapPoint(m_lastMouseCoord.x(), m_lastMouseCoord.y());
pointo.setX(mapPoint.x());
pointo.setY(mapPoint.y());
m_extentRectangle.setTopLeft(pointo);
m_extentRectangle.setWidth(20000);
m_extentRectangle.setHeight(20000);

EsriRuntimeQt::Point topLeftMapPoint = Point(pointo.x(), pointo.y());
EsriRuntimeQt::Point bottomRightMapPoint = Point(m_extentRectangle.bottomRight().x(), m_extentRectangle.bottomRight().y());

// create and set the extent
m_cacheExtent = EsriRuntimeQt::Envelope(topLeftMapPoint.x(), bottomRightMapPoint.y(), bottomRightMapPoint.x(), topLeftMapPoint.y());
poly2.startPath(m_extentRectangle.topLeft().x(),m_extentRectangle.topLeft().y());
poly2.lineTo(m_extentRectangle.topRight().x(), m_extentRectangle.topRight().y());
poly2.lineTo(m_extentRectangle.bottomRight().x(), m_extentRectangle.bottomRight().y());
poly2.lineTo(m_extentRectangle.bottomLeft().x(), m_extentRectangle.bottomLeft().y());
poly2.closePathWithLine();
EsriRuntimeQt::SimpleLineSymbol line2(QColor(0,0,0), 1);
EsriRuntimeQt::SimpleFillSymbol simpleFillSym2(QColor(165,42,42,255), EsriRuntimeQt::SimpleFillSymbolStyle::DiagonalCross, line2);
EsriRuntimeQt::Graphic graphic21(poly2, simpleFillSym2);
m_graphicsLayer.addGraphic(graphic21);
m_mapAction->setChecked(false);

EsriRuntimeQt::GenerateTileCacheParameters params(true, QList<double>() << 0 << 1 << 2 << 3 << 4,EsriRuntimeQt::ExportBy::Id,m_cacheExtent,m_map.spatialReference());
QString tileCachePath = "../../temp/test.tpk";
QFile downloadFile(tileCachePath);
QDir downloadDir(tileCachePath);

// Submit the task and download the file
m_tileCacheTask.submitTileCacheJobAndDownload(params, tileCachePath);

Outcomes