Exemple #1
0
        /// <summary>
        /// Creates ag3.DCurve from a geometry
        /// </summary>
        /// <param name="curve"> this curve</param>
        /// <param name="geom"> the OGR geometry to ue as ths source</param>
        /// <param name="crs"> the crs to u for the DCurve3 DEFAULT map default projections or EPG:4326 if none</param>
        /// <returns></returns>
        public static DCurve3 FromGeometry(this DCurve3 curve, Geometry geom, SpatialReference crs = null)
        {
            if (geom.GetSpatialReference() == null)
            {
                if (crs != null)
                {
                    geom.AssignSpatialReference(crs);
                }
                else
                {
                    geom.AssignSpatialReference(AppState.instance.projectCrs);
                }
            }
            if (geom.TransformTo(AppState.instance.mapProj) != 0)
            {
                throw new NotSupportedException("projection failed");
            }
            if (geom.Transform(AppState.instance.mapTrans) != 0)
            {
                throw new NotSupportedException("axis change failed");
            }
            int n = geom.GetPointCount();

            Vector3d[] ls = new Vector3d[n];
            for (int i = 0; i < n; i++)
            {
                double[] argout = new double[3];
                geom.GetPoint(i, argout);
                ls[i] = new Vector3d(argout);
            }
            curve.ClearVertices();
            curve.SetVertices(ls);
            curve.Closed = geom.IsRing();
            return(curve);
        }
Exemple #2
0
 /// <summary>
 /// Creates g3.DCurve from Vector3[]
 /// </summary>
 /// <param name="curve">DCurve</param>
 /// <param name="verteces">Vextor3[]</param>
 /// <param name="bClosed">whether the line is closed</param>
 public static DCurve3 Vector3(this DCurve3 curve, Vector3[] verteces, bool bClosed)
 {
     curve.ClearVertices();
     curve.Closed = bClosed;
     foreach (Vector3 vertex in verteces)
     {
         curve.AppendVertex(vertex);
     }
     return(curve);
 }