public class ShapefileLoader
extends java.lang.Object
This class loads map data from a Shapefile and produces a LineMap object, which can be used by the leJOS navigation package.
There are many map editors which can use the Shapefile format (OpenEV, Global Mapper). Once you have created a map, export it as Shapefile. This will produce three files ending in .shp .shx and .dbf. The only file used by this class is .shp.
NOTE: Shapefiles can only contain one type of shape data (polygon or polyline, not both). A single file can't mix polylines with polygons.
This class' code can parse points and multipoints. However, a LineMap object can't deal with points (only lines) so points and multipoints are discarded.
Modifier and Type | Field and Description |
---|---|
(package private) java.io.DataInputStream |
data_is |
private static byte |
MULTIPOINT |
private static byte |
NULL_SHAPE |
private static byte |
POINT |
private static byte |
POLYGON |
private static byte |
POLYLINE |
private int |
SHAPEFILE_ID |
Constructor and Description |
---|
ShapefileLoader(java.io.InputStream in)
Creates a ShapefileLoader object using an input stream.
|
Modifier and Type | Method and Description |
---|---|
private double |
readLEDouble()
Reads a little endian double into a big endian double
|
private int |
readLEInt()
Translates a little endian int into a big endian int
|
private long |
readLELong()
Translates a little endian long into a big endian long
|
LineMap |
readLineMap()
Retrieves a LineMap object from the Shapefile input stream.
|
private static final byte NULL_SHAPE
private static final byte POINT
private static final byte POLYLINE
private static final byte POLYGON
private static final byte MULTIPOINT
private final int SHAPEFILE_ID
java.io.DataInputStream data_is
public ShapefileLoader(java.io.InputStream in)
in
- public LineMap readLineMap() throws java.io.IOException
java.io.IOException
private int readLEInt() throws java.io.IOException
java.io.IOException
private final double readLEDouble() throws java.io.IOException
java.io.IOException
private long readLELong() throws java.io.IOException
java.io.IOException