ArcGIS Pro is not displaying a point that was programmatically added.

294
4
Jump to solution
05-17-2022 11:12 PM
BillSmith
New Contributor III

This code is being executed and it returns true.

The new point feature says it has been added and you can see it in the attribute table.

Yet it won't draw or jump to the point like any others that were added in ArcGIS Pro directory.

Any ideas?

 

Thanks,

-Bill

 

Code snippet.

var edit_op = new EditOperation();

edit_op.Name = $"Create {layer.Name}";
edit_op.SelectNewFeatures = true;
edit_op.Create(layer.FeatureLayer, attributes);
bool result = edit_op.Execute();

SfaLogger.Log("Return from insert operation is: " + result.ToString());

 

BTW:

I have something very similar in ArcGIS Desktop using ArcObject code and the same point inserts and

is drawn fine in ArcMap.  The point coming into the API from our software is identical in both cases.

1 Solution

Accepted Solutions
BillSmith
New Contributor III

That s a great catch.  Thank you.  I think I have seen this problem before with the projection engine casting to the wrong types but didn't catch it.

View solution in original post

0 Kudos
4 Replies
GintautasKmieliauskas
Regular Contributor

Hi,

Have you tried Esri ArcGIS Pro sample https://github.com/Esri/arcgis-pro-sdk-community-samples/tree/master/Editing/AddFeatureTest ?

I think issue is with "attributes" variable setting or points spatial reference. If your points don't have spatial reference then they could be somewhere on map.

0 Kudos
BillSmith
New Contributor III

Yes,

We are doing something very similar when setting the Shape attribute.

 

Coordinate3D pt;
pt.X = BitConverter.ToDouble(data, offset);
offset += sizeof(double);
pt.Y = BitConverter.ToDouble(data, offset);
offset += sizeof(double);
pt.Z = BitConverter.ToDouble(data, offset);

MapPointBuilder builder = new MapPointBuilder(pt, _sfa_util.GeoCS);
builder.HasZ = layer.HasZ;
builder.HasM = layer.HasM;

if (builder.HasM) {
builder.M = 0.0;
}

MapPoint geom = builder.ToGeometry() as MapPoint;
Coordinate3D projected_geom;

if (layer.SpatialRef.HasVcs) {
ProjectionTransformation proj_trans =
ProjectionTransformation.CreateWithVertical(_sfa_util.GeoCS, layer.SpatialRef);

projected_geom = (Coordinate3D)GeometryEngine.Instance.ProjectEx(geom, proj_trans);

} else {
projected_geom = (Coordinate3D)GeometryEngine.Instance.Project(geom, layer.SpatialRef);
}

layer.map_point = geom;

attributes[layer.GeomField] = projected_geom;

 

 

It returns true and the exact same point is sent into ArcGIS Desktop, via another plugin, which works fine.

The same code is called for lines and polygons and they draw fine.

 

Thanks anyways.

0 Kudos
NarelleChedzey
Esri Contributor

Hi Bill, 

 

Looking at your code above - you are actually assigning a Coordinate3D to the geometry field in your attributes collection.  You actually need to be assigning a MapPoint.   

A Coordinate3D is only a lightweight structure and is not the same as a MapPoint.  The point feature class expects a geometry of type MapPoint. 

 

You can fix this by not casting the result of the GeometryEngine ProjectEx or Project routines to Coordinate3D but casting the result to a MapPoint.   This should fix your problem. 

 

Thanks

Narelle

BillSmith
New Contributor III

That s a great catch.  Thank you.  I think I have seen this problem before with the projection engine casting to the wrong types but didn't catch it.

0 Kudos