com.supermap.data

Class GeoRegion



  • public class GeoRegion
    extends Geometry
    The polygon geometry class is derived from the Geometry class.

    This class is used to depict the regional geographical entities, such as lake, administrative areas and residential lots, etc. , using one or more sets of points.he GeoRegion object can have one or multiple parts, and each part is represented by an ordered set of points . Note that the start point and endpoint in an ordered set of points that form a part is identical. You can add, delete and modify a part of the GeoRegion.

    • Constructor Summary

      Constructors 
      Constructor and Description
      GeoRegion()
      Constructs a new GeoRegion object.
      GeoRegion(GeoRegion region)
      Initializes a new instance identical to the given GeoRegion object.
      GeoRegion(Point2Ds points)
      Creates a new GeoRegion object according to the specified arguments.
    • Constructor Detail

      • GeoRegion

        public GeoRegion()
        Constructs a new GeoRegion object.
      • GeoRegion

        public GeoRegion(GeoRegion region)
        Initializes a new instance identical to the given GeoRegion object.
        Parameters:
        region - The specified GeoRegion object.
      • GeoRegion

        public GeoRegion(Point2Ds points)
        Creates a new GeoRegion object according to the specified arguments.
        Parameters:
        points - The ordered set of points used to create the GeoRegion.
        Throws:
        java.lang.IllegalArgumentException - if the count of points in the ordered point colection is less than 3.
    • Method Detail

      • getArea

        public double getArea()
        Returns the area of the GeoRegion object. If a GeoRegion objects has many subobjects, its area is the sum of all the subobjects.
        Returns:
        the area of the GeoRegion object.
        See Also:
        getPerimeter()
        Default:
        The default value is 0.0.
      • getPartCount

        public int getPartCount()
        Returns the count of parts of the GeoRegion object. After being cleared, the count of the parts is 0.
        Returns:
        the count of the subobjects of the GeoRegion object.
        Default:
        The default value is 0.0.
      • getPerimeter

        public double getPerimeter()
        Returns the perimeter of the GeoRegion object. Its perimeter is the sum of the perimeters of all parts.
        Returns:
        the perimeter of the GeoRegion object.
        Default:
        The default value is 0.0.
      • isEmpty

        public boolean isEmpty()
        Returns whether the GeoRegion object is empty, that is whether it has on subobjects. For the number of sub objects, see the getPartCount() method.
        Overrides:
        isEmpty in class Geometry
        Returns:
        Returns true if the object is empty.
      • clone

        public GeoRegion clone()
        Returns a copy of the current GeoRegion object.
        Specified by:
        clone in class Geometry
        Returns:
        The GeoRegion object obtained by cloning.
      • dispose

        public void dispose()
        Release the resource occupy by this object.
        Overrides:
        dispose in class Geometry
      • addPart

        public int addPart(Point2Ds points)
        Appends a part to this GeoRegion object.
        Parameters:
        points - the ordered point collection that forms the parts.
        Returns:
        If successful, this method will return the index number of the new added part, otherwise it will return -1.
        Throws:
        java.lang.IllegalArgumentException - if the count of points in the ordered point colection is less than 3.
        See Also:
        insertPart(int,Point2Ds), removePart(int)
      • convertToLine

        public GeoLine convertToLine()
        Converts the GeoRegion object to a GeoLine object. Returns the GeoLine object if succeed.
        Returns:
        A GeoLine object, if succeeded.
      • getPart

        public Point2Ds getPart(int index)
        Returns the subobject with the specified index in the GeoLine object, return the subobject in form of a ordered point collection.
        Parameters:
        index - The subobject index.
        Returns:
        the ordered point collection that composes the parts.
        Throws:
        java.lang.IndexOutOfBoundsException - If the serial number crossed.
        See Also:
        setPart(int,Point2Ds)
      • insertPart

        public boolean insertPart(int index,
                                  Point2Ds points)
        Inserts a subobject to the GeoRegion object at specified place. If succeeded, this method will return true; otherwise false. Insert the copy of the ordered point collection. The modify of the source ordered point collection will not affect the GeoRegion, use the setPart() method to modify the GeoRegion object.
        Parameters:
        index - The position to insert the part.
        points - The ordered set of points whose copy will form the part to be inserted.
        Returns:
        True, if succeeded; otherwise false.
        Throws:
        java.lang.IllegalArgumentException - if the count of points in the ordered point colection is less than 3.
        java.lang.IndexOutOfBoundsException - If the serial number crossed.
        See Also:
        addPart(Point2Ds), removePart(int)
      • removePart

        public boolean removePart(int index)
        Removes the subobject of the GeoRegion object with the specified index.
        Parameters:
        index - The index number of the part to be removed.
        Returns:
        Returns true if it is removed successfully; false otherwise.
        Throws:
        java.lang.IndexOutOfBoundsException - If the serial number crossed.
        See Also:
        addPart(Point2Ds), insertPart(int,Point2Ds)
      • setPart

        public boolean setPart(int index,
                               Point2Ds points)
        Modify the subobject with the given index of the GeoRegion object.
        Parameters:
        index - The index number of the part to be removed.
        points - The ordered set of points used to replace the parts.
        Returns:
        True, if successful; Otherwise false.
        Throws:
        java.lang.IllegalArgumentException - if the count of points in the ordered point colection is less than 3.
        java.lang.IndexOutOfBoundsException - If the serial number crossed.
        See Also:
        getPart(int)