예제 #1
0
        /// <summary>
        /// Returs Kml representation of the point. Note: Z,M values are igonred
        /// </summary>
        /// <returns></returns>
        static IRI.Ket.KmlFormat.Primitives.PlacemarkType AsPlacemark(PolyLineZ polyline, Func <IRI.Ham.SpatialBase.Point, IRI.Ham.SpatialBase.Point> projectToGeodeticFunc = null, byte[] color = null)
        {
            IRI.Ket.KmlFormat.Primitives.PlacemarkType placemark =
                new KmlFormat.Primitives.PlacemarkType();

            List <IRI.Ket.KmlFormat.Primitives.LineStringType> linestrings =
                new List <KmlFormat.Primitives.LineStringType>();

            IRI.Ket.KmlFormat.Primitives.MultiGeometryType multiGeometry =
                new KmlFormat.Primitives.MultiGeometryType();

            IEnumerable <string> coordinates;

            if (projectToGeodeticFunc != null)
            {
                coordinates = polyline.parts
                              .Select(i =>
                                      string.Join(" ", ShapeHelper.GetPoints(polyline, i)
                                                  .Select(j =>
                {
                    var temp = projectToGeodeticFunc(new IRI.Ham.SpatialBase.Point(j.X, j.Y));
                    return(string.Format("{0},{1}", temp.X, temp.Y));
                }).ToArray()));
            }
            else
            {
                coordinates = polyline.Parts
                              .Select(i =>
                                      string.Join(" ", ShapeHelper.GetPoints(polyline, i)
                                                  .Select(j => string.Format("{0},{1}", j.X, j.Y))
                                                  .ToArray()));
            }

            foreach (string item in coordinates)
            {
                IRI.Ket.KmlFormat.Primitives.LineStringType linestring = new KmlFormat.Primitives.LineStringType();

                linestring.coordinates = item;

                linestrings.Add(linestring);
            }

            multiGeometry.AbstractGeometryObjectExtensionGroup = linestrings.ToArray();

            placemark.AbstractFeatureObjectExtensionGroup = new KmlFormat.Primitives.AbstractObjectType[] { multiGeometry };

            return(placemark);
        }
예제 #2
0
        /// <summary>
        /// Returs Kml representation of the point. Note: Point must be in Lat/Long System
        /// </summary>
        /// <returns></returns>
        public IRI.Ket.KmlFormat.Primitives.PlacemarkType AsPlacemark(Func <IRI.Msh.Common.Primitives.Point, IRI.Msh.Common.Primitives.Point> projectToGeodeticFunc = null, byte[] color = null)
        {
            IRI.Ket.KmlFormat.Primitives.PlacemarkType placemark = new KmlFormat.Primitives.PlacemarkType();

            IRI.Ket.KmlFormat.Primitives.PointType point = new KmlFormat.Primitives.PointType();

            IRI.Msh.Common.Primitives.Point coordinates = new Point(this.x, this.Y);

            if (projectToGeodeticFunc != null)
            {
                coordinates = projectToGeodeticFunc(new Point(this.X, this.Y));
            }

            point.coordinates = string.Format(System.Globalization.CultureInfo.InvariantCulture, "{0:G17},{1:G17}", coordinates.X, coordinates.Y);

            //placemark.AbstractFeatureObjectExtensionGroup = new KmlFormat.Primitives.AbstractObjectType[] { point };
            placemark.AbstractGeometry = point;

            return(placemark);
        }
예제 #3
0
        /// <summary>
        /// Returs Kml representation of the point. Note: Point must be in Lat/Long System
        /// </summary>
        /// <returns></returns>
        static IRI.Ket.KmlFormat.Primitives.PlacemarkType AsPlacemark(EsriPolyline polyline, Func <IRI.Msh.Common.Primitives.Point, IRI.Msh.Common.Primitives.Point> projectToGeodeticFunc = null, byte[] color = null)
        {
            IRI.Ket.KmlFormat.Primitives.PlacemarkType placemark =
                new KmlFormat.Primitives.PlacemarkType();

            List <IRI.Ket.KmlFormat.Primitives.LineStringType> linestrings =
                new List <KmlFormat.Primitives.LineStringType>();

            IRI.Ket.KmlFormat.Primitives.MultiGeometryType multiGeometry =
                new KmlFormat.Primitives.MultiGeometryType();

            IEnumerable <string> coordinates;

            if (projectToGeodeticFunc != null)
            {
                coordinates = polyline.parts
                              .Select(i =>
                                      string.Join(" ", ShapeHelper.GetEsriPoints(polyline, i)
                                                  .Select(j =>
                {
                    var temp = projectToGeodeticFunc(new IRI.Msh.Common.Primitives.Point(j.X, j.Y));
                    return(string.Format("{0},{1}", temp.X, temp.Y));
                }).ToArray()));
            }
            else
            {
                coordinates = polyline.parts
                              .Select(i =>
                                      string.Join(" ", ShapeHelper.GetEsriPoints(polyline, i)
                                                  .Select(j => string.Format("{0},{1}", j.X, j.Y))
                                                  .ToArray()));
            }

            foreach (string item in coordinates)
            {
                IRI.Ket.KmlFormat.Primitives.LineStringType linestring = new KmlFormat.Primitives.LineStringType();

                linestring.coordinates = item;

                linestrings.Add(linestring);
            }

            multiGeometry.AbstractGeometry = linestrings.ToArray();

            //placemark.AbstractFeatureObjectExtensionGroup = new KmlFormat.Primitives.AbstractObjectType[] { multiGeometry };
            placemark.AbstractGeometry = multiGeometry;
            //IRI.Ket.KmlFormat.Primitives.MultiGeometryType t = new KmlFormat.Primitives.MultiGeometryType();

            if (color == null)
            {
                return(placemark);
            }

            IRI.Ket.KmlFormat.Primitives.StyleType style =
                new KmlFormat.Primitives.StyleType();

            KmlFormat.Primitives.LineStyleType lineStyle = new KmlFormat.Primitives.LineStyleType();
            lineStyle.color = color;

            style.LineStyle  = lineStyle;
            placemark.Styles = new KmlFormat.Primitives.AbstractStyleSelectorType[] { style };

            return(placemark);
        }
예제 #4
0
 internal static string AsKml(KmlFormat.Primitives.PlacemarkType placemark)
 {
     return(AsKml(new KmlFormat.Primitives.AbstractFeatureType[] { placemark }));
 }