Example #1
0
        public Polygon ImportPolygon(ISOPolygon isoPolygon)
        {
            Polygon          polygon   = new Polygon();
            LineStringMapper lsgMapper = new LineStringMapper(TaskDataMapper);
            ISOLineString    exterior  = isoPolygon.LineStrings.FirstOrDefault(l => l.LineStringType == ISOLineStringType.PolygonExterior);

            if (exterior != null)
            {
                polygon.ExteriorRing = lsgMapper.ImportLinearRing(exterior);
            }
            polygon.InteriorRings = new List <LinearRing>();
            polygon.InteriorRings.AddRange(lsgMapper.ImportLinearRings(isoPolygon.LineStrings.Where(l => l.LineStringType == ISOLineStringType.PolygonInterior)));
            return(polygon);
        }
Example #2
0
        /// <summary>
        /// Returns an ADAPT Polygon for ISOPolygons defined with Exterior/Interior rings.  Null otherwise
        /// </summary>
        /// <param name="isoPolygon"></param>
        /// <returns></returns>
        public Polygon ImportBoundaryPolygon(ISOPolygon isoPolygon)
        {
            if (IsFieldAttributeType(isoPolygon))
            {
                //Polygon is defined as an area of interest and not a PFD/TZN boundary, etc.
                return(null);
            }

            ISOLineString exteriorRing = isoPolygon.LineStrings.FirstOrDefault(l => l.LineStringType == ISOLineStringType.PolygonExterior);
            IEnumerable <ISOLineString> interiorRings = isoPolygon.LineStrings.Where(l => l.LineStringType == ISOLineStringType.PolygonInterior);

            if (exteriorRing != null || interiorRings.Any())
            {
                Polygon          polygon   = new Polygon();
                LineStringMapper lsgMapper = new LineStringMapper(TaskDataMapper);
                if (exteriorRing != null)
                {
                    polygon.ExteriorRing = lsgMapper.ImportLinearRing(exteriorRing);
                }
                polygon.InteriorRings = lsgMapper.ImportLinearRings(interiorRings).ToList();
                return(polygon);
            }
            return(null);
        }
Example #3
0
        /// <summary>
        /// Returns an ADAPT Polygon for ISOPolygons defined with Exterior/Interior rings.  Null otherwise
        /// </summary>
        /// <param name="isoPolygon"></param>
        /// <returns></returns>
        public IEnumerable <Polygon> ImportBoundaryPolygon(ISOPolygon isoPolygon, bool isVersion3Multipolygon)
        {
            if (IsFieldAttributeType(isoPolygon))
            {
                //Polygon is defined as an area of interest and not a PFD/TZN boundary, etc.
                return(null);
            }

            LineStringMapper lsgMapper = new LineStringMapper(TaskDataMapper);
            List <Polygon>   output    = new List <Polygon>();

            if (isVersion3Multipolygon)
            {
                //Version 3 only allowed one polygon for the boundary with multiple external linestrings acting as individual polygons
                foreach (ISOLineString ls in isoPolygon.LineStrings)
                {
                    if (ls.LineStringType == ISOLineStringType.PolygonExterior)
                    {
                        Polygon polygon = new Polygon {
                            ExteriorRing = lsgMapper.ImportLinearRing(ls)
                        };
                        if (isoPolygon.PolygonDesignator != null)
                        {
                            polygon.ContextItems.Add(new ContextItem()
                            {
                                Code = "Pr_ISOXML_Attribute_Designator", Value = isoPolygon.PolygonDesignator
                            });
                        }
                        output.Add(polygon);
                    }
                    else if (ls.LineStringType == ISOLineStringType.PolygonInterior)
                    {
                        //We will interpret any interior linestrings as belonging to the preceeding external linestring
                        output.Last().InteriorRings.Add(lsgMapper.ImportLinearRing(ls));
                    }
                }
            }
            else
            {
                //Normal Polygon behavior with only one possible exterior ring.
                ISOLineString exteriorRing = isoPolygon.LineStrings.FirstOrDefault(l => l.LineStringType == ISOLineStringType.PolygonExterior);
                IEnumerable <ISOLineString> interiorRings = isoPolygon.LineStrings.Where(l => l.LineStringType == ISOLineStringType.PolygonInterior);
                if (exteriorRing != null || interiorRings.Any())
                {
                    Polygon polygon = new Polygon();
                    if (exteriorRing != null)
                    {
                        polygon.ExteriorRing = lsgMapper.ImportLinearRing(exteriorRing);
                    }
                    polygon.InteriorRings = lsgMapper.ImportLinearRings(interiorRings).ToList();
                    if (isoPolygon.PolygonDesignator != null)
                    {
                        polygon.ContextItems.Add(new ContextItem()
                        {
                            Code = "Pr_ISOXML_Attribute_Designator", Value = isoPolygon.PolygonDesignator
                        });
                    }
                    output.Add(polygon);
                }
            }
            return(output);
        }