Class MapComposedElement

    • Constructor Detail

      • MapComposedElement

        public MapComposedElement​(UUID id,
                                  AttributeCollection attributeSource)
        Create a new map element.
        Parameters:
        id - is the unique identifier of this element, or null if unknown.
        attributeSource - is the source of the attributes for this map element.
        Since:
        4.0
    • Method Detail

      • equals

        @Pure
        public boolean equals​(MapElement element)
        Replies if the specified objects is the same as this one.

        If the specified object is a MapComposedElement, these points are matched to the points of this object. If the specified object is not a MapcomposedElement, this function replies false

        Specified by:
        equals in class MapElement
        Parameters:
        element - the element to compare to.
        Returns:
        true if the given element is equal to this object, otherwise false
      • contains

        @Pure
        public boolean contains​(Point2D<?,​?> point,
                                double delta)
        Replies if the specified point (x,y) was inside the figure of this MapElement.
        Specified by:
        contains in class MapElement
        Parameters:
        point - is a geo-referenced coordinate
        delta - is the geo-referenced distance that corresponds to a approximation distance in the screen coordinate system
        Returns:
        true if the specified point has a distance nearest than delta to this element, otherwise false
      • getGeoLocation

        @Pure
        public GeoLocation getGeoLocation()
        Description copied from interface: GISPrimitive
        Replies the geo-location.

        A GeoLocation is unique according to the geo-location of the element. If two elements have the same points in the same order, or if two elements have the same points in a reverse order, they must have equal GeoLocations.

        The following code is always true (where the arguments of the constructors are the list of points of the polyline). It illustrates that for two elements with the same geo-localized points, they have the same geo-location identifier (Geo-Id) and they have different unique ientifier (Uid):

        
         GISElement obj1 = new MapPolyline(100,10,200,30,300,4);
         GISElement obj2 = new MapPolyline(100,10,200,30,300,4);
         assert( obj1.getGeoId().equals(obj2.getGeoId()) );
         assert( obj2.getGeoId().equals(obj1.getGeoId()) );
         assert( ! obj1.getUid().equals(obj2.getUid()) );
         assert( ! obj2.getUid().equals(obj1.getUid()) );
         
        Returns:
        a location
        See Also:
        GISPrimitive.getGeoId(), GISPrimitive.getGeoLocation()
      • clear

        public void clear()
        Remove all the points.
      • getGroupCount

        @Pure
        public int getGroupCount()
        Replies the count of groups.
        Returns:
        the count of groups.
      • getPointCount

        @Pure
        public int getPointCount()
        Replies the count of points in all the parts.
        Returns:
        the count of points
      • containsPoint

        @Pure
        public boolean containsPoint​(Point2D<?,​?> point)
        Check if point p is contained in this coordinates collections.
        Parameters:
        point - the point to compare with this coordinates
        Returns:
        true if p is already part of coordinates
      • containsPoint

        @Pure
        public boolean containsPoint​(Point2D<?,​?> point,
                                     int groupIndex)
        Check if point p is contained in this coordinates collections.
        Parameters:
        point - the point to compare with this coordinates
        groupIndex - into look for
        Returns:
        true if p is already part of coordinates
      • getPointCountInGroup

        @Pure
        public int getPointCountInGroup​(int groupIndex)
        Replies the count of points in the specified group.
        Parameters:
        groupIndex - the group index.
        Returns:
        the count of points in the specified group.
        Throws:
        IndexOutOfBoundsException - in case of error.
      • getPointIndex

        @Pure
        public int getPointIndex​(int groupIndex,
                                 int position)
        Replies the global index of the point that corresponds to the position in the given group.
        Parameters:
        groupIndex - the group index.
        position - is the index of the point in the group
        Returns:
        the global index of the point
        Throws:
        IndexOutOfBoundsException - in case of error.
      • getPointIndex

        @Pure
        public int getPointIndex​(int groupIndex,
                                 Point2D<?,​?> point2d)
        Replies the global index of the point2d in the given group.
        Parameters:
        groupIndex - the group index.
        point2d - is the point in the group
        Returns:
        the global index of the point or -1 if not found
      • getFirstPointIndexInGroup

        @Pure
        public int getFirstPointIndexInGroup​(int groupIndex)
        Replies the global index of the point that starts a group.
        Parameters:
        groupIndex - the group index.
        Returns:
        the index of the first point in the group
        Throws:
        IndexOutOfBoundsException - in case of error.
      • getLastPointIndexInGroup

        @Pure
        public int getLastPointIndexInGroup​(int groupIndex)
        Replies the global index of the point that ends a group.
        Parameters:
        groupIndex - the group index.
        Returns:
        the index of the last point in the group
        Throws:
        IndexOutOfBoundsException - in case of error.
      • points

        @Pure
        public Iterable<Point2d> points()
        Replies the iterator on the points.
        Returns:
        the iterator on the points.
      • pointIterator

        @Pure
        public Iterator<Point2d> pointIterator()
        Replies the iterator on the points.
        Returns:
        the iterator on the points.
      • addPoint

        public final int addPoint​(Point2D<?,​?> point)
        Add the specified point at the end of the last group.
        Parameters:
        point - the new point.
        Returns:
        the index of the new point in the element.
      • addPoint

        public int addPoint​(double x,
                            double y)
        Add the specified point at the end of the last group.
        Parameters:
        x - x coordinate
        y - y coordinate
        Returns:
        the index of the new point in the element.
      • addPoint

        public final int addPoint​(Point2D<?,​?> point,
                                  int indexGroup)
        Add the specified point at the end of the specified group.
        Parameters:
        point - the new point.
        indexGroup - the index of the group.
        Returns:
        the index of the point in the element.
        Throws:
        IndexOutOfBoundsException - in case of error.
      • addPoint

        public int addPoint​(double x,
                            double y,
                            int groupIndex)
        Add the specified point at the end of the specified group.
        Parameters:
        x - x coordinate
        y - y coordinate
        groupIndex - the index of the group.
        Returns:
        the index of the point in the element.
        Throws:
        IndexOutOfBoundsException - in case of error.
      • addGroup

        public final void addGroup​(Point2D<?,​?> point)
        Add the specified point into a newgroup.
        Parameters:
        point - the point.
      • addGroup

        public int addGroup​(double x,
                            double y)
        Add the specified point into a newgroup.
        Parameters:
        x - x coordinate
        y - y coordinate
        Returns:
        the index of the new point in this element.
      • invertPointsIn

        public MapComposedElement invertPointsIn​(int groupIndex)
        invert the points coordinates of this element on the groupIndex in argument.

        This method is reversible: this.invertPointsIn(sameIndex) == this.invertPointsIn(sameIndex).invertPointsIn(sameIndex)

        NOTE: invert each parts with invertPointsIn(int) does'nt produce the same result as invert().

        This method invert points coordinates only. this.invertPointsIn(0 .. indexCount) != this.invert()

        Parameters:
        groupIndex - int element on which invert points
        Returns:
        this
      • invert

        public MapComposedElement invert()
        Invert the order of points coordinates of this element and reorder the groupIndex too.

        NOTE: invert each parts with invertPointsIn(int) does'nt produce the same result as invert()

        This method invert points coordinates AND start index of parts to keep the logical order of points this method is reversible

        this.invert() == this.invert().invert()

        Returns:
        the inverted element
      • insertPointAt

        public final int insertPointAt​(Point2D<?,​?> point,
                                       int indexGroup,
                                       int indexInGroup)
        Insert the specified point at the given index in the specified group.
        Parameters:
        point - is the point to insert
        indexGroup - is the index of the group
        indexInGroup - is the index of the ponit in the group (0 for the first point of the group...).
        Returns:
        the index of the new point in the element.
        Throws:
        IndexOutOfBoundsException - in case of error.
      • insertPointAt

        public int insertPointAt​(double x,
                                 double y,
                                 int groupIndex,
                                 int indexInGroup)
        Insert the specified point at the given index in the specified group.
        Parameters:
        x - is the point to insert
        y - is the point to insert
        groupIndex - is the index of the group
        indexInGroup - is the index of the ponit in the group (0 for the first point of the group...).
        Returns:
        the index of the new point in the element.
        Throws:
        IndexOutOfBoundsException - in case of error.
      • getPointAt

        @Pure
        public Point2d getPointAt​(int index)
        Replies the specified point at the given index.

        If the index is negative, it will corresponds to an index starting from the end of the list.

        Parameters:
        index - is the index of the desired point
        Returns:
        the point at the given index
        Throws:
        IndexOutOfBoundsException - in case of error.
      • getPointAt

        @Pure
        public Point2d getPointAt​(int groupIndex,
                                  int indexInGroup)
        Replies the specified point at the given index in the specified group.
        Parameters:
        groupIndex - is the index of the group
        indexInGroup - is the index of the point in the group (0 for the first point of the group...).
        Returns:
        the point
        Throws:
        IndexOutOfBoundsException - in case of error.
      • setPointAt

        public final boolean setPointAt​(int index,
                                        double x,
                                        double y)
        Set the specified point at the given index.

        If the index is negative, it will corresponds to an index starting from the end of the list.

        Parameters:
        index - is the index of the desired point
        x - is the new value of the point
        y - is the new value of the point
        Returns:
        true if the point was set, false if the specified coordinates correspond to the already existing point.
        Throws:
        IndexOutOfBoundsException - in case of error.
      • setPointAt

        public boolean setPointAt​(int index,
                                  double x,
                                  double y,
                                  boolean canonize)
        Set the specified point at the given index.

        If the index is negative, it will corresponds to an index starting from the end of the list.

        Parameters:
        index - is the index of the desired point
        x - is the new value of the point
        y - is the new value of the point
        canonize - indicates if the function canonize(int) must be called.
        Returns:
        true if the point was set, false if the specified coordinates correspond to the already existing point.
        Throws:
        IndexOutOfBoundsException - in case of error.
      • setPointAt

        public final boolean setPointAt​(int index,
                                        Point2D<?,​?> point)
        Set the specified point at the given index.

        If the index is negative, it will corresponds to an index starting from the end of the list.

        Parameters:
        index - is the index of the desired point
        point - is the new value of the point
        Returns:
        true if the point was set, false if the specified coordinates correspond to the already existing point.
        Throws:
        IndexOutOfBoundsException - in case of error.
      • setPointAt

        public final boolean setPointAt​(int index,
                                        Point2D<?,​?> point,
                                        boolean canonize)
        Set the specified point at the given index.

        If the index is negative, it will corresponds to an index starting from the end of the list.

        Parameters:
        index - is the index of the desired point
        point - is the new value of the point
        canonize - indicates if the function canonize(int) must be called.
        Returns:
        true if the point was set, false if the specified coordinates correspond to the already existing point.
        Throws:
        IndexOutOfBoundsException - in case of error.
      • setPointAt

        public final boolean setPointAt​(int groupIndex,
                                        int indexInGroup,
                                        double x,
                                        double y)
        Set the specified point at the given index in the specified group.
        Parameters:
        groupIndex - is the index of the group
        indexInGroup - is the index of the ponit in the group (0 for the first point of the group...).
        x - is the new value.
        y - is the new value.
        Returns:
        true if the point was set, false if the specified coordinates correspond to the already existing point.
        Throws:
        IndexOutOfBoundsException - in case of error
      • setPointAt

        public boolean setPointAt​(int groupIndex,
                                  int indexInGroup,
                                  double x,
                                  double y,
                                  boolean canonize)
        Set the specified point at the given index in the specified group.
        Parameters:
        groupIndex - is the index of the group
        indexInGroup - is the index of the ponit in the group (0 for the first point of the group...).
        x - is the new value.
        y - is the new value.
        canonize - indicates if the function canonize(int) must be called.
        Returns:
        true if the point was set, false if the specified coordinates correspond to the already existing point.
        Throws:
        IndexOutOfBoundsException - in case of error.
      • setPointAt

        public final boolean setPointAt​(int groupIndex,
                                        int indexInGroup,
                                        Point2D<?,​?> point)
        Set the specified point at the given index in the specified group.
        Parameters:
        groupIndex - is the index of the group
        indexInGroup - is the index of the ponit in the group (0 for the first point of the group...).
        point - is the new value.
        Returns:
        true if the point was set, false if the specified coordinates correspond to the already existing point.
        Throws:
        IndexOutOfBoundsException - in case of error.
      • setPointAt

        public final boolean setPointAt​(int groupIndex,
                                        int indexInGroup,
                                        Point2D<?,​?> point,
                                        boolean canonize)
        Set the specified point at the given index in the specified group.
        Parameters:
        groupIndex - is the index of the group
        indexInGroup - is the index of the ponit in the group (0 for the first point of the group...).
        point - is the new value.
        canonize - indicates if the function canonize(int) must be called.
        Returns:
        true if the point was set, false if the specified coordinates correspond to the already existing point.
        Throws:
        IndexOutOfBoundsException - in case of error.
      • removeGroupAt

        public boolean removeGroupAt​(int groupIndex)
        Remove the specified group.
        Parameters:
        groupIndex - the index of the group.
        Returns:
        true on success, otherwise false
      • removePointAt

        public Point2d removePointAt​(int groupIndex,
                                     int indexInGroup)
        Remove the specified point at the given index in the specified group.
        Parameters:
        groupIndex - is the index of the group
        indexInGroup - is the index of the ponit in the group (0 for the first point of the group...).
        Returns:
        the removed point
        Throws:
        IndexOutOfBoundsException - in case of error.
      • canonize

        public boolean canonize()
        Remove unnecessary points from the specified index.
        Returns:
        true if points are removed, otherwise false