Package lejos.robotics.mapping
Class LineMap
- java.lang.Object
-
- lejos.robotics.mapping.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
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidcreateSVGFile(java.lang.String fileName)Create an SVG map filevoiddumpObject(java.io.DataOutputStream dos)Dump the map to a DataOutputStreamLineMapflip()Create a line map with the y axis flippedRectanglegetBoundingRect()Return the bounding rectangle of the mapped areaLine[]getLines()Get the lines as an arraybooleaninside(Point p)Check if a point is within the mapped areavoidloadObject(java.io.DataInputStream dis)Load a map from a DataInputStreamfloatrange(Pose pose)Calculate the range of a robot to the nearest wall
-
-
-
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 segmentsboundingRect- 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
-
inside
public boolean inside(Point p)
Check if a point is within the mapped area
-
getBoundingRect
public Rectangle getBoundingRect()
Return the bounding rectangle of the mapped area- Specified by:
getBoundingRectin interfaceRangeMap- Returns:
- the bounding rectangle
-
dumpObject
public void dumpObject(java.io.DataOutputStream dos) throws java.io.IOExceptionDump the map to a DataOutputStream- Specified by:
dumpObjectin interfaceTransmittable- Parameters:
dos- the stream- Throws:
java.io.IOException
-
loadObject
public void loadObject(java.io.DataInputStream dis) throws java.io.IOExceptionLoad a map from a DataInputStream- Specified by:
loadObjectin interfaceTransmittable- 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.IOExceptionCreate 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
-
-