AnsweredAssumed Answered

What would cause an 'Incompatible spatial references' error when creating a multipoint.

Question asked by ufshall on Dec 22, 2017
Latest reply on Dec 27, 2017 by cmacleod-esristaff

I currently dealing with an 'Incompatible spatial references' exception when I try to create a Multipoint from an enumeration of MapPoints.The points are kept in an object that stores the user's mouse clicks on the map or entering a lat/lon through text boxes on a Dockpanel. The MapPoints created all have the same spatial reference.

The points entered through the text boxes are projected from the GCS to the spatial reference of the MapView since we work in state plane systems. Those points will show correctly on the map but when trying to use them they fail to comply. The error occurs in this function:

 

        protected internal async void UpdateMapViewOverlay()
        {
            var UserBoundsVm = UfsProTools.UserBoundsVm;
            var mapView = MapView.Active;
            List<MapPoint> points = new List<MapPoint>();

            List<UserPlotObject> userPlots = UserBoundsVm._UserPlotObject.OrderBy(o => o.UserNumber).ToList();

            await QueuedTask.Run(() =>
            {
                foreach (UserPlotObject plot in userPlots)
                {
                    points.Add(plot.UserEntryPoint);
                }
                using (MultipointBuilder pointBuilder = new MultipointBuilder(points))
                {
                    Multipoint multiPoint = pointBuilder.ToGeometry();

                    var markerSymbol = SymbolFactory.Instance.ConstructMarker(ColorFactory.Instance.RedRGB, 12.0, SimpleMarkerStyle.Diamond);
                    var pointSymbol = SymbolFactory.Instance.ConstructPointSymbol(markerSymbol);
                    var disposable = mapView.AddOverlay(multiPoint, pointSymbol.MakeSymbolReference());

                    if (points.Count > 1)
                    {
                        using (PolylineBuilder lineBuilder = new PolylineBuilder(multiPoint))
                        {
                            Polyline polyline = lineBuilder.ToGeometry();
                            var lineStyle = SymbolFactory.Instance.ConstructLineSymbol(ColorFactory.Instance.BlueRGB, 2.0,
                                SimpleLineStyle.Solid);

                            mapView.UpdateOverlay(disposable, polyline, lineStyle.MakeSymbolReference());
                        }
                    }
                }
            });
        }

 

The error occurs when the MultipointBuilder tries to create the pointBuilder from the points enumeration. What would cause this to happen?

 

Thank you in advance for any help!

 

Scott

Outcomes