예제 #1
0
        /// <summary>
        /// Returns an ADAPT Polygon for ISOPolygons describing field points of interest.  Null otherwise
        /// </summary>
        /// <param name="isoPolygon"></param>
        /// <returns></returns>
        public AttributeShape ImportAttributePolygon(ISOPolygon isoPolygon)
        {
            Polygon boundaryPolygon = ImportBoundaryPolygon(isoPolygon, false)?.FirstOrDefault();

            if (boundaryPolygon != null && IsFieldAttributeType(isoPolygon))
            {
                //The data has defined an explicit PLN type that maps to an attribute type
                return(new AttributeShape()
                {
                    Shape = boundaryPolygon,
                    TypeName = Enum.GetName(typeof(ISOPolygonType), isoPolygon.PolygonType),
                    Name = isoPolygon.PolygonDesignator
                });
            }
            else if (isoPolygon.LineStrings.Count == 1)
            {
                //If no linestrings defined as interior/exterior, we expect only 1 linestring
                ISOLineString attributeLsg = isoPolygon.LineStrings.FirstOrDefault(ls => LineStringMapper.IsFieldAttributeType(ls));
                if (attributeLsg != null)
                {
                    LineStringMapper lsgMapper = new LineStringMapper(TaskDataMapper);
                    Polygon          polygon   = new Polygon()
                    {
                        ExteriorRing = lsgMapper.ImportLinearRing(attributeLsg)
                    };
                    return(new AttributeShape()
                    {
                        Shape = polygon,
                        TypeName = Enum.GetName(typeof(ISOPolygonType), isoPolygon.PolygonType),
                        Name = isoPolygon.PolygonDesignator
                    });
                }
            }
            return(null);  //This polygon does not map to an InteriorBoundaryAttribute.
        }
예제 #2
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);
        }
예제 #3
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);
        }
예제 #4
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);
        }