Select to view content in your preferred language

JSON Parser error when loading TPK as an Elevation Source. QT WINDOWS 10

1604
4
Jump to solution
03-06-2021 01:21 PM
SPI_LLC_1
Emerging Contributor

I been having issues loading a TPK file into my application for QT.  To start from a know quantity i used the MontereyElevation.tpk file that is in the examples.   https://developers.arcgis.com/qt/cpp/sample-code/create-terrain-surface-from-a-local-tile-package/

from the Example executables i could not run the file with a 3d topology.  Instead it displays a flat map.

 

in my own code samples i use the following lines:

-----------------------

const QString tile_elevation_package_path = QString{"d://temp/export/MontereyElevation.tpk"};

// Before attempting to add any layers, check that the file for the elevation source exists at all.
const bool src_elevation_file_exists = QFileInfo::exists(tile_elevation_package_path);

if(src_elevation_file_exists) {
qInfo() << "elevation source package found";
ArcGISTiledElevationSource* elevationsrc=new ArcGISTiledElevationSource{QUrl("file:"+tile_elevation_package_path), this};
// When the elevation source is finished loading, call the elevationSrcFinishedLoading callback, so we can tell if it loaded succesfully.
connect(elevationSrc, &ArcGISTiledElevationSource::doneLoading, this, &Add_layers_to_a_3d_scene::packageLoaded);

// add the elevation source to the scene to display elevation
m_scene->baseSurface()->elevationSources()->append(elevationSrc);
} else {
qInfo() << "elevation source file not found";
}

----------------------------------

 

void Add_layers_to_a_3d_scene::packageLoaded(const Error& e)
{
if (!e.isEmpty())
{
qDebug() << QString("Package load error: %1 %2").arg(e.message(), e.additionalMessage());
return;
}

}

 

the error code i receive:

"Package load error: JSON parser invalid start of JSON. Error processing service metadata response.\nP : 0"

 

I have experienced this same error with  my own LERC TPK generated from ARCGIS Pro.  

 

Thanks in advance!

 

 

0 Kudos
1 Solution

Accepted Solutions
Tanner_Yould
Esri Contributor

Hi @SPI_LLC_1, unfortunately I'm having trouble replicating your issue. Are you able to run the unmodified Create terrain surface from local tile package sample provided from our GitHub repo? You'll need to add the Monterey Elevation TPK to the file path like `<username>/ArcGIS/Runtime/Data/tpk/MontereyElevation.tpk`.

And also, just to double check, what version of Qt and version of ArcGIS Runtime are you using?

I'm thinking that either there's a problem on the back end with Qt or the Runtime API being out of date, or it's something to do with these lines of code where you load the file:

const QString tile_elevation_package_path = QString{"d://temp/export/MontereyElevation.tpk"};

ArcGISTiledElevationSource* elevationsrc=new ArcGISTiledElevationSource{QUrl("file:"+tile_elevation_package_path), this};

 

In our sample, we use the following syntax, but I confirmed that either works.

// CreateTerrainSurfaceFromLocalTilePackage.cpp

const QString montereyTileElevationPath = QString{defaultDataPath() + "/ArcGIS/Runtime/Data/tpk/MontereyElevation.tpk"}; // defaultDataPath() is defined on lines 39-52

ArcGISTiledElevationSource* elevationsrc=new ArcGISTiledElevationSource{montereyTileElevationPath, this};

 

Sorry I can't be of more help initially, but I'm hoping we can resolve this soon!

Thanks!

- Tanner

Tanner Yould
Product Engineer
ArcGIS Maps SDK for Native Apps
Esri

View solution in original post

0 Kudos
4 Replies
Tanner_Yould
Esri Contributor

Hi @SPI_LLC_1, unfortunately I'm having trouble replicating your issue. Are you able to run the unmodified Create terrain surface from local tile package sample provided from our GitHub repo? You'll need to add the Monterey Elevation TPK to the file path like `<username>/ArcGIS/Runtime/Data/tpk/MontereyElevation.tpk`.

And also, just to double check, what version of Qt and version of ArcGIS Runtime are you using?

I'm thinking that either there's a problem on the back end with Qt or the Runtime API being out of date, or it's something to do with these lines of code where you load the file:

const QString tile_elevation_package_path = QString{"d://temp/export/MontereyElevation.tpk"};

ArcGISTiledElevationSource* elevationsrc=new ArcGISTiledElevationSource{QUrl("file:"+tile_elevation_package_path), this};

 

In our sample, we use the following syntax, but I confirmed that either works.

// CreateTerrainSurfaceFromLocalTilePackage.cpp

const QString montereyTileElevationPath = QString{defaultDataPath() + "/ArcGIS/Runtime/Data/tpk/MontereyElevation.tpk"}; // defaultDataPath() is defined on lines 39-52

ArcGISTiledElevationSource* elevationsrc=new ArcGISTiledElevationSource{montereyTileElevationPath, this};

 

Sorry I can't be of more help initially, but I'm hoping we can resolve this soon!

Thanks!

- Tanner

Tanner Yould
Product Engineer
ArcGIS Maps SDK for Native Apps
Esri
0 Kudos
SPI_LLC_1
Emerging Contributor

Thanks the error was trivial

"d://temp/export/MontereyElevation.tpk

the double // kills the loading.  Which leads me to follow up.  The monterrey.tpk loads fine.  But when generating my own it has errors.  Is a tutorial that shows how to make a monterrey.tpk file so that i can learn to generate my own compatible tpk file?

i have tried following tutorials to generate a using lerc encoding.  My package throws and error tiling scheme resolution unsupported.

 

 

 

 

0 Kudos
Tanner_Yould
Esri Contributor

I'm glad to see it was an easy fix. As for generating your own elevation tpks, I don't believe we have a tutorial for that at the Runtime level because that's generally done through ArcGIS Pro.

Are you able to read the tpk files you create in ArcGIS Pro? If not, perhaps it would be worth following up in that forum? I did some initial searching for you and perhaps this tutorial on how to share a tile package may be worthwhile if you haven't already seen it.

If it does work in Pro but not in the Runtime API, please let me know because that's something that I'll want to bring up to the team.

Thanks again,

Tanner

Tanner Yould
Product Engineer
ArcGIS Maps SDK for Native Apps
Esri
0 Kudos
SPI_LLC_1
Emerging Contributor

Thanks yes I am using ArcGIS Pro.  And I can read both TPK's without problems, but Have no idea what the requirements or difference with the packages.  I do not know what makes my generated TPK not compatible with the runtime SDK

0 Kudos