org.squigle.layers
Class Layer

java.lang.Object
  |
  +--org.squigle.layers.Layer
Direct Known Subclasses:
PointLayer, PolygonLayer, PolyLineLayer

public abstract class Layer
extends java.lang.Object

Layer is the abstract base class of all layer implementations. Layers each represent a specific aspect of a geographic area. A layer has a uniform rendering style (color, linewidth, etc) as well as being composed of a one of three geometric data types (point, polyline, polygon). Layers can be either readable or writable. Writable layers start out as empty, unsorted layers that allow geometry and metadata to be added to them. Readable layers are layers where their data is fully populated, sorted, and optimized for display and searching. Readable layers are created by loading a pregenerated layer, or by calling the sort() function on a populated writable layer. Readable layers can be writen to a channel for later use as a pre-rendered layer.

Layers each have their own paint() function that can be overridden for custom rendering needs. Layers also can register a metaDataHandler which can handle how metaData is rendered or processed by the rest of the application. A StreetNameMetaDataHandler would handle positioning and rendering of street names for a polyline layer that stores local road data. A HwyBadgeMetaDataHandler would handle the rendering and positioning of Highway badge graphics for a polyline layer that represents major highways.

Finally, layers can be made searchable. By passing a bounding box to the query() function of a searchable layer, an array of metaData records found within that bounding box are returned.


Field Summary
 int height
          Since the layer also has a render component, we must know the drawing plane dimensions
 float max_threshold
           
 float min_threshold
          Thresholds determine the zoom range at which the layer is visible.
 float screenDiag
          the current viewport diagonal
 double vp_lat_1
           
 double vp_lat_2
           
 double vp_lon_1
           
 double vp_lon_2
           
 int width
          Since the layer also has a render component, we must know the drawing plane dimensions
 
Constructor Summary
Layer(java.nio.ByteBuffer geoData, int geoDataPointer, java.nio.ByteBuffer metaData, int metaDataHeaderPointer, org.squigle.layers.MetaDataHandler metaDataHandler)
          Constructor for a readable layer
Layer(float lon_1, float lat_1, float lon_2, float lat_2, java.awt.Color renderColor, int renderWidth, int geometryType, java.lang.String[] metaDataHeaders, org.squigle.layers.MetaDataHandler metaDataHandler)
          Constructor for writable layer
 
Method Summary
static boolean boundsCollision(float[] p1, float[] p2, float[] p3, float[] p4)
           
 void free()
           
abstract  void paint(java.awt.Graphics g)
          Each layer needs a paint function that can render the layers geometry
abstract  java.lang.String[][] query(float lon_1, float lat_1, float lon_2, float lat_2)
          Search a layer for metaData within the bounding coordinates
abstract  int sort(int maxWeight, int maxDepth)
          The sort function processes the element from a writable layer, sorting them into a BSP tree with a depth no greater than maxDepth, and no more than maxWeight elements per node.
abstract  int write(java.io.RandomAccessFile raf)
          Writes a readable layer to a random access file handle Must be overridden to handle writing specific geometries
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

vp_lon_1

public double vp_lon_1

vp_lat_1

public double vp_lat_1

vp_lon_2

public double vp_lon_2

vp_lat_2

public double vp_lat_2

width

public int width
Since the layer also has a render component, we must know the drawing plane dimensions


height

public int height
Since the layer also has a render component, we must know the drawing plane dimensions


min_threshold

public float min_threshold
Thresholds determine the zoom range at which the layer is visible. They represents the viewport diagonal (in miles) which the layer is visible


max_threshold

public float max_threshold

screenDiag

public float screenDiag
the current viewport diagonal

Constructor Detail

Layer

public Layer(float lon_1,
             float lat_1,
             float lon_2,
             float lat_2,
             java.awt.Color renderColor,
             int renderWidth,
             int geometryType,
             java.lang.String[] metaDataHeaders,
             org.squigle.layers.MetaDataHandler metaDataHandler)
Constructor for writable layer

Parameters:
lon_1 - the upper left intitude of layer
lat_1 - the upper left latitude of layer
lon_2 - the lower right intitude of layer
lat_2 - the lower right latitude of layer
renderColor - the color to render the layer as
renderWidth - the thickness of the elements rendered
geometryType - the geometry of the layer (point, polyline, polygon)
metaDataHeaders - the column headers for the layers metadata

Layer

public Layer(java.nio.ByteBuffer geoData,
             int geoDataPointer,
             java.nio.ByteBuffer metaData,
             int metaDataHeaderPointer,
             org.squigle.layers.MetaDataHandler metaDataHandler)
Constructor for a readable layer

Parameters:
geoData - a refrence to a ByteBuffer that contains the layer data
geoDataPointer - a byte offset in the geoData ByteBuffer that points to the start of the geoData layer
metaData - a refrence to a ByteBuffer that containts the layer's metadata
metaDataHeaderPointer - a byte offset in the metaData ByteBuffer that points to the layers header definitions
Method Detail

free

public void free()

sort

public abstract int sort(int maxWeight,
                         int maxDepth)
The sort function processes the element from a writable layer, sorting them into a BSP tree with a depth no greater than maxDepth, and no more than maxWeight elements per node. Depth overrides weight in cases where the max depth is reached but the node has more elements than maxWeight. On completion, sort sets readable = true. This function must be overridden to handle sorting of diffrent geometries.

Parameters:
maxWeight - the maximum elements a node should hold before splitting
maxDepth - the maximum depth nodes are allowed to split
Returns:
the number of elements processed

paint

public abstract void paint(java.awt.Graphics g)
Each layer needs a paint function that can render the layers geometry

Parameters:
g - the Graphics object the layer is rendered to

query

public abstract java.lang.String[][] query(float lon_1,
                                           float lat_1,
                                           float lon_2,
                                           float lat_2)
Search a layer for metaData within the bounding coordinates

Parameters:
lon_1 - the upper left intitude to search from
lat_1 - the upper left latitude to search from
lon_2 - the lower right intitude to search to
lat_2 - the lower right latitude to search to
Returns:
an array of metaData String[]'s

write

public abstract int write(java.io.RandomAccessFile raf)
                   throws java.io.IOException
Writes a readable layer to a random access file handle Must be overridden to handle writing specific geometries

Parameters:
raf - the random access file to write the layer to
Returns:
the filepointer to the root of the layer
java.io.IOException

boundsCollision

public static boolean boundsCollision(float[] p1,
                                      float[] p2,
                                      float[] p3,
                                      float[] p4)