Ejemplo n.º 1
0
        private static GeoAPILineString FromLineString(ILineString geometry, GeoAPIGeometryFactory factory, bool copyUserData)
        {
            var coordinates = FromCoordinates(geometry.Coordinates);
            var result      = (geometry is ILinearRing)
                       ? factory.CreateLinearRing(coordinates)
                       : factory.CreateLineString(coordinates);

            if (copyUserData)
            {
                result.UserData = geometry.UserData;
            }
            return(result);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets the line for the specified index
        /// </summary>
        /// <param name="shape">The shape to convert</param>
        /// <param name="factory">The geometry factory to use.</param>
        /// <param name="copyAttributes">A value indicating whether or not to copy the <see cref="Data.Shape.Attributes"/> to <see cref="GeoAPIGeometry.UserData"/></param>
        /// <returns>The geometry representing the converted shape.</returns>
        private static GeoAPIGeometry FromLineShape(Data.Shape shape, GeoAPIGeometryFactory factory, bool copyAttributes)
        {
            var lines = new List <GeoAPILineString>();

            foreach (var part in shape.Range.Parts)
            {
                var i      = part.StartIndex;
                var coords = new List <GeoAPICoordinate>();
                foreach (var d in part)
                {
                    var c = new GeoAPICoordinate(d.X, d.Y);
                    coords.Add(c);
                    //if (shape.HasM()) c.M = M[i];
                    if (shape.HasZ())
                    {
                        c.Z = shape.Z[i];
                    }
                    i++;
                }
                lines.Add(factory.CreateLineString(coords.ToArray()));
            }
            if (lines.Count == 1)
            {
                if (copyAttributes)
                {
                    lines[0].UserData = shape.Attributes;
                }
                return(lines[0]);
            }

            var ret = factory.CreateMultiLineString(lines.ToArray());

            if (copyAttributes)
            {
                ret.UserData = shape.Attributes;
            }
            return(ret);
        }
        /// <summary>
        /// Gets the line for the specified index
        /// </summary>
        /// <param name="shape">The shape to convert</param>
        /// <param name="factory">The geometry factory to use.</param>
        /// <param name="copyAttributes">A value indicating whether or not to copy the <see cref="Data.Shape.Attributes"/> to <see cref="GeoAPIGeometry.UserData"/></param>
        /// <returns>The geometry representing the converted shape.</returns>
        private static GeoAPIGeometry FromLineShape(Data.Shape shape, GeoAPIGeometryFactory factory, bool copyAttributes)
        {
            var lines = new List<GeoAPILineString>();
            foreach (var part in shape.Range.Parts)
            {
                var i = part.StartIndex;
                var coords = new List<GeoAPICoordinate>();
                foreach (var d in part)
                {
                    var c = new GeoAPICoordinate(d.X, d.Y);
                    coords.Add(c);
                    //if (shape.HasM()) c.M = M[i];
                    if (shape.HasZ()) c.Z = shape.Z[i];
                    i++;
                }
                lines.Add(factory.CreateLineString(coords.ToArray()));
            }
            if (lines.Count == 1)
            {
                if (copyAttributes)
                    lines[0].UserData = shape.Attributes;
                return lines[0];
            }

            var ret = factory.CreateMultiLineString(lines.ToArray());
            if (copyAttributes)
                ret.UserData = shape.Attributes;
            return ret;
        }
 private static GeoAPILineString FromLineString(ILineString geometry, GeoAPIGeometryFactory factory, bool copyUserData)
 {
     var coordinates = FromCoordinates(geometry.Coordinates);
     var result = (geometry is ILinearRing)
                ? factory.CreateLinearRing(coordinates)
                : factory.CreateLineString(coordinates);
     if (copyUserData)
         result.UserData = geometry.UserData;
     return result;
 }