Unable to create 3D geometries with Pro SDK ImportFromJSON

472
2
Jump to solution
03-12-2021 10:59 AM
Labels (3)
JamesWright9
New Contributor III

I am attempting to import some 3d geometry via json into ArcGIS Pro using the Pro SDK; however, I am having some issues.

I am trying to create a 3D Polyline geometry in pro via the following Pro SDK code in .NET:

GeometryEngine.Instance.ImportFromJSON(JSONImportFlags.jsonImportDefaults, geometryJson);

The call succeeds and i am provided a valid Geometry however the Z coordinates are ignored and the HasZ is set to false? Is this a bug or am I maybe missing something?

Here is the json I am passing in via the geometryJson variable. As you can see the z values are provided for each coordinate and the vertical spatial references are noted. Any help would be appreicated.

{
"paths": [
[
[
12712034.466200002,
2553465.0080999993,
0.0
],
[
12712036.5786,
2553461.9959999993,
-2.0
],
[
12712036.625100002,
2553461.9448999986,
-2.0
],
[
12712036.672600001,
2553461.9134000018,
-2.0
]
]
],
"spatialReference": {
"wkid": 3857,
"latestWkid": 3857,
"vcsWkid": 105703,
"latestVcsWkid": 6360
}
}

0 Kudos
1 Solution

Accepted Solutions
NarelleChedzey
Esri Contributor

Hi James, 

 

The expected format of a JSON string that supports Zs would have the "hasZ" attribute included.  Here's an example of JSON string for a polyline that supports Zs. 

{"hasZ":true,"paths":[[[100,200,3],[201,300,4],[301,400,5],[401,500,6]]],"spatialReference":{"wkid":102100,"latestWkid":3857}}

 

If that attribute is included, then the geometry resulting from the ImportFromJSON will have .HasZ = true 

Hope this helps. 

 

Narelle

 

View solution in original post

0 Kudos
2 Replies
NarelleChedzey
Esri Contributor

Hi James, 

 

The expected format of a JSON string that supports Zs would have the "hasZ" attribute included.  Here's an example of JSON string for a polyline that supports Zs. 

{"hasZ":true,"paths":[[[100,200,3],[201,300,4],[301,400,5],[401,500,6]]],"spatialReference":{"wkid":102100,"latestWkid":3857}}

 

If that attribute is included, then the geometry resulting from the ImportFromJSON will have .HasZ = true 

Hope this helps. 

 

Narelle

 

0 Kudos
JamesWright9
New Contributor III

Narelle,

Thanks for responding! That makes complete sense, I thought I must be missing something simple. Our data structures don't have that concept of a 'z' flag, instead simply check the data, so I didn't think of it that way, but this works great!

Thanks again, life saver!

James

0 Kudos