sagulnet / winforms-geplugin-control-library

Automatically exported from code.google.com/p/winforms-geplugin-control-library
GNU General Public License v3.0
0 stars 0 forks source link

GEHelpers.CreateLineString overload for taking multiple coordinates #51

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
        /// <summary>
        /// Draws a line string between the given coordinates
        /// </summary>
        /// <param name="ge">The plugin instance</param>
        /// <param name="coordinates">List of points</param>
        /// <param name="id">Optional ID of the linestring placemark. Default is empty</param>
        /// <param name="tessellate">Optionally sets tessellation for the linestring. Default is true</param>
        /// <param name="addFeature">Optionally adds the linestring directly to the plugin. Default is true</param>
        /// <returns>A linestring placemark (or false)</returns>
        public static object CreateLineString(
            dynamic ge,
            dynamic coordinates,
            string id = "",
            bool tessellate = true,
            bool addFeature = true)
        {
            if (!IsGe(ge))
            {
                throw new ArgumentException("ge is not of the type GEPlugin");
            }

            try
            {
                dynamic placemark = CreatePlacemark(ge, addFeature: addFeature);
                dynamic lineString = ge.createLineString(string.Empty);                
                lineString.setTessellate(Convert.ToUInt16(tessellate));

                foreach( Coordinate c in coordinates )
                {                   
                    lineString.getCoordinates().pushLatLngAlt(c.Latitude, c.Longitude, c.Altitude);                    
                }

                placemark.setGeometry(lineString);

                return placemark;
            }
            catch (RuntimeBinderException rbex)
            {
                Debug.WriteLine("CreateLineString: " + rbex.ToString(), "GEHelpers");
            }

            return false;
        }

Original issue reported on code.google.com by joe.wake...@gmail.com on 24 Aug 2011 at 7:32

GoogleCodeExporter commented 8 years ago
[deleted comment]
GoogleCodeExporter commented 8 years ago
Will review this and probably add it to the next release, many thanks Joe, top 
stuff.

Original comment by fraser.c...@gmail.com on 26 Aug 2011 at 8:57

GoogleCodeExporter commented 8 years ago
Hi, I am adding this now - the only changes I have made being the type of the 
coordinates parameter. There is no need to invoke the DLR using the dynamic 
type as the Coordinate class is defined in managed code, so

"dynamic coordinates"

Should be either...

Coordinate[] coordinates

or something like...

List<Coordinate> coordinates

Thanks again for the input!

Fraser

Original comment by fraser.c...@gmail.com on 7 Feb 2012 at 8:15