Beispiel #1
0
 public static void LoadReservoirSurfacesFromLayer(List <ReservoirSurface> surfaces, BasicFeatureLayer surfacesLayer)
 {
     using (var cursor = surfacesLayer.Search())
     {
         while (cursor.MoveNext())
         {
             using (Row row = cursor.Current)
             {
                 ReservoirSurface reservoirSurface = new ReservoirSurface();
                 reservoirSurface.ObjectID = (int)row["ObjectID"];
                 reservoirSurface.DamID    = (int)row["DamID"];
                 reservoirSurface.Polygon  = (row as Feature).GetShape() as Polygon;
                 surfaces.Add(reservoirSurface);
             }
         }
     }
 }
        private static async Task PolygonsForContours(List <CandidateDam> candidates, List <Contour> contours, PolylineBuilder polylineBuilder)
        {
            foreach (var contour in contours)
            {
                var contourGeometry = contour.Polyline;
                int counter         = 0;
                int contourHeight   = 0;
                foreach (var candidate in candidates.Where(c => c.ContourID == contour.ObjectID).ToList())
                {
                    try
                    {
                        while (polylineBuilder.CountParts > 0)
                        {
                            polylineBuilder.RemovePart(0);
                        }

                        //add the full contour
                        polylineBuilder.AddParts(contourGeometry.Parts);
                        //split at the endpoint
                        polylineBuilder.SplitAtDistance(candidate.EndPointDistance, false, true);

                        if (candidate.DamSpansContourStart)
                        {
                            //remove the part of the contour after the endpoint
                            //split at the startpoint
                            if (candidate.StartPointDistance != 0)
                            {
                                polylineBuilder.SplitAtDistance(candidate.StartPointDistance, false, true);
                                //remove the part of the polyline before the startpoint
                                polylineBuilder.RemovePart(1);
                            }
                            //Handle the situation, when the startpoint is on the very beginning of the contour line
                            else
                            {
                                polylineBuilder.RemovePart(0);
                            }
                        }
                        else
                        {
                            //remove the part of the contour after the endpoint
                            polylineBuilder.RemovePart(1);
                            //split at the startpoint
                            if (candidate.StartPointDistance != 0)
                            {
                                polylineBuilder.SplitAtDistance(candidate.StartPointDistance, false, true);
                                //remove the part of the polyline before the startpoint
                                polylineBuilder.RemovePart(0);
                            }
                        }
                        var newPolygon3D = PolygonBuilder.CreatePolygon(polylineBuilder.ToGeometry().Copy3DCoordinatesToList(), SpatialReference);

                        ReservoirSurface surface = new ReservoirSurface();
                        surface.Polygon       = GeometryEngine.Instance.Move(newPolygon3D, 0, 0, candidate.ContourHeight) as Polygon;
                        surface.DamID         = (long)candidate.ObjectID;
                        surface.ContourHeight = (short)candidate.ContourHeight;
                        surfaces.Add(surface);

                        counter++;
                        contourHeight = candidate.ContourHeight;
                    }
                    catch (Exception ex)
                    {
                        SharedFunctions.Log("Error for DamID " + candidate.ObjectID + " for ContourHeight " + candidate.ContourHeight + ": (" + ex.Message + ")");
                    }
                }

                SharedFunctions.Log("Created " + surfaces.Count.ToString("N0") + " Polygons ... " + counter.ToString("N0") + " for Contour " + contour.ObjectID + " (" + contour.Height + " m)");
            }
        }