Class LineMap

  • All Implemented Interfaces:
    RangeMap, Transmittable

    public class LineMap
    extends java.lang.Object
    implements RangeMap, Transmittable
    A map of a room or other closed environment, represented by line segments
    Author:
    Lawrie Griffiths
    • Constructor Summary

      Constructors 
      Constructor Description
      LineMap()
      Constructor to use when map will be loaded from a data stream
      LineMap​(Line[] lines, Rectangle boundingRect)
      Create a map from an array of line segments and a bounding rectangle
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void createSVGFile​(java.lang.String fileName)
      Create an SVG map file
      void dumpObject​(java.io.DataOutputStream dos)
      Dump the map to a DataOutputStream
      LineMap flip()
      Create a line map with the y axis flipped
      Rectangle getBoundingRect()
      Return the bounding rectangle of the mapped area
      Line[] getLines()
      Get the lines as an array
      boolean inside​(Point p)
      Check if a point is within the mapped area
      void loadObject​(java.io.DataInputStream dis)
      Load a map from a DataInputStream
      float range​(Pose pose)
      Calculate the range of a robot to the nearest wall
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LineMap

        public LineMap​(Line[] lines,
                       Rectangle boundingRect)
        Create a map from an array of line segments and a bounding rectangle
        Parameters:
        lines - the line segments
        boundingRect - the bounding rectangle
      • LineMap

        public LineMap()
        Constructor to use when map will be loaded from a data stream
    • Method Detail

      • range

        public float range​(Pose pose)
        Calculate the range of a robot to the nearest wall
        Specified by:
        range in interface RangeMap
        Parameters:
        pose - the pose of the robot
        Returns:
        the range or -1 if not in range
      • inside

        public boolean inside​(Point p)
        Check if a point is within the mapped area
        Specified by:
        inside in interface RangeMap
        Parameters:
        p - the Point
        Returns:
        true iff the point is with the mapped area
      • getBoundingRect

        public Rectangle getBoundingRect()
        Return the bounding rectangle of the mapped area
        Specified by:
        getBoundingRect in interface RangeMap
        Returns:
        the bounding rectangle
      • dumpObject

        public void dumpObject​(java.io.DataOutputStream dos)
                        throws java.io.IOException
        Dump the map to a DataOutputStream
        Specified by:
        dumpObject in interface Transmittable
        Parameters:
        dos - the stream
        Throws:
        java.io.IOException
      • loadObject

        public void loadObject​(java.io.DataInputStream dis)
                        throws java.io.IOException
        Load a map from a DataInputStream
        Specified by:
        loadObject in interface Transmittable
        Parameters:
        dis - the stream
        Throws:
        java.io.IOException
      • getLines

        public Line[] getLines()
        Get the lines as an array
        Returns:
        the lines as an array
      • createSVGFile

        public void createSVGFile​(java.lang.String fileName)
                           throws java.io.IOException
        Create an SVG map file
        Parameters:
        fileName - the name of the file to create or overwrite
        Throws:
        java.io.IOException
      • flip

        public LineMap flip()
        Create a line map with the y axis flipped
        Returns:
        the new LineMap