lejos.robotics.mapping
Class LineMap

java.lang.Object
  extended by lejos.robotics.mapping.LineMap
All Implemented Interfaces:
RangeMap, Transmittable

public class LineMap
extends Object
implements RangeMap, Transmittable

A map of a room or other closed environment, represented by line segments

Author:
Lawrie Griffiths

Constructor Summary
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
 void createSVGFile(String fileName)
          Create an SVG map file
 void dumpObject(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(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(DataOutputStream dos)
                throws IOException
Dump the map to a DataOutputStream

Specified by:
dumpObject in interface Transmittable
Parameters:
dos - the stream
Throws:
IOException

loadObject

public void loadObject(DataInputStream dis)
                throws IOException
Load a map from a DataInputStream

Specified by:
loadObject in interface Transmittable
Parameters:
dis - the stream
Throws:
IOException

getLines

public Line[] getLines()
Get the lines as an array

Returns:
the lines as an array

createSVGFile

public void createSVGFile(String fileName)
                   throws IOException
Create an SVG map file

Parameters:
fileName - the name of the file to create or overwrite
Throws:
IOException

flip

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

Returns:
the new LineMap