Ejemplo n.º 1
0
        public static IEnumerable ImportKml(
            SqlString kml,
            SqlBoolean makeValid)
        {
            if (kml == null || string.IsNullOrEmpty(kml.Value))
            {
                return(new Collection <GeographyContext>());
            }

            var geographies = new Collection <GeographyContext>();

            var parser =
                new Import.KMLProcessor(kml.Value.Trim());

            foreach (var p in parser.Geographies)
            {
                var ge = new GeographyContext
                {
                    Id = p.Id, Context = p.Context, Shape = p.ToSqlGeography(makeValid.Value)
                };

                geographies.Add(ge);
            }

            return(geographies);
        }
Ejemplo n.º 2
0
        public static SqlGeography KmlToGeography(
            SqlString kml,
            SqlBoolean makeValid)
        {
            if (kml == null || string.IsNullOrEmpty(kml.Value))
            {
                return(SqlGeography.Null);
            }

            var constructed = new SqlGeographyBuilder();
            var parser      = new Import.KMLProcessor(kml.Value.Trim());

            parser.Populate(constructed, makeValid.Value);
            return(constructed.ConstructedGeography);
        }