org.ala.layers.intersect
Class ComplexRegion

java.lang.Object
  extended by org.ala.layers.intersect.SimpleRegion
      extended by org.ala.layers.intersect.ComplexRegion
All Implemented Interfaces:
java.io.Serializable

public class ComplexRegion
extends SimpleRegion

ComplexRegion is a collection of SimpleRegion, expect POLYGONs for now. treat as a shape file, overlapping regions cancel out presence. TODO: clockwise/anticlockwise identification

Author:
Adam Collins
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.ala.layers.intersect.SimpleRegion
BOUNDING_BOX, CIRCLE, GI_ABSENCE, GI_FULLY_PRESENT, GI_PARTIALLY_PRESENT, GI_UNDEFINED, POLYGON, UNDEFINED
 
Constructor Summary
ComplexRegion()
          Constructor for empty ComplexRegion
 
Method Summary
 void addPolygon(SimpleRegion sr)
          adds a new polygon note: if a mask is in use must call useMask again
 int[][] fillAccMask_EPSG900913(int startPolygon, int endPolygon, double longitude1, double latitude1, double longitude2, double latitude2, int width, int height, byte[][] three_state_map, boolean noCellsReturned)
           
 int[][] fillAccMask(int startPolygon, int endPolygon, double longitude1, double latitude1, double longitude2, double latitude2, int width, int height, byte[][] three_state_map, boolean noCellsReturned)
           
 double[][] getBoundingBox()
          gets the bounding box for shapes in this ComplexRegion
 int[][] getOverlapGridCells_EPSG900913(double longitude1, double latitude1, double longitude2, double latitude2, int width, int height, byte[][] three_state_map, boolean noCellsReturned)
           
 int[][] getOverlapGridCells(double longitude1, double latitude1, double longitude2, double latitude2, int width, int height, byte[][] three_state_map, boolean noCellsReturned)
          determines overlap with a grid for type POLYGON when three_state_map is not null populate it with one of: GI_UNDEFINED GI_PARTIALLY_PRESENT GI_FULLY_PRESENT GI_ABSENCE
 int getValue()
          gets integer value stored
 boolean isWithin_EPSG900913(double longitude, double latitude)
           
 boolean isWithin(double longitude, double latitude)
          returns true when the point provided is within the ComplexRegion uses mask when available note: type UNDEFINED implies no boundary, always returns true.
static SimpleRegion parseComplexRegion(java.lang.String[] polygons)
           
 void setValue(int value_)
          sets integer value stored
 void useMask(int width, int height, int depthThreashold)
          builds a grid (mask) to speed up isWithin.
 
Methods inherited from class org.ala.layers.intersect.SimpleRegion
convertLatToPixel, convertLngToPixel, convertMetersToLat, convertMetersToLng, convertMetersToPixels, convertPixelsToMeters, convertPixelToLat, convertPixelToLng, fillAccMask_EPSG900913, fillAccMask, getHeight, getNumberOfPoints, getOverlapGridCells_Acc_EPSG900913, getOverlapGridCells_Acc, getOverlapGridCells_Box, getOverlapGridCells_EPSG900913, getOverlapGridCells_Polygon_Acc_EPSG900913, getOverlapGridCells_Polygon_Acc, getOverlapGridCells_Polygon_EPSG900913, getOverlapGridCells_Polygon, getOverlapGridCells, getType, getWidth, parseSimpleRegion, saveGridAsImage, setBox, setCircle, setNone, setPolygon
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComplexRegion

public ComplexRegion()
Constructor for empty ComplexRegion

Method Detail

parseComplexRegion

public static SimpleRegion parseComplexRegion(java.lang.String[] polygons)

setValue

public void setValue(int value_)
sets integer value stored

Parameters:
value_ - as int

getValue

public int getValue()
gets integer value stored

Returns:
int

getBoundingBox

public double[][] getBoundingBox()
gets the bounding box for shapes in this ComplexRegion

Overrides:
getBoundingBox in class SimpleRegion
Returns:
bounding box for ComplexRegion as double [][]

addPolygon

public void addPolygon(SimpleRegion sr)
adds a new polygon note: if a mask is in use must call useMask again

Parameters:
points_ - points = double[n][2] where n is number of points [][0] is longitude [][1] is latitude

isWithin

public boolean isWithin(double longitude,
                        double latitude)
returns true when the point provided is within the ComplexRegion uses mask when available note: type UNDEFINED implies no boundary, always returns true.

Overrides:
isWithin in class SimpleRegion
Parameters:
longitude -
latitude -
Returns:
true iff point is within or on the edge of this ComplexRegion

useMask

public void useMask(int width,
                    int height,
                    int depthThreashold)
builds a grid (mask) to speed up isWithin. TODO: split out shapes with large numbers of points in GI_PARTIALLY_PRESENT grid cells. TODO: automatic(best) height/width specification

Parameters:
width -
height -

getOverlapGridCells

public int[][] getOverlapGridCells(double longitude1,
                                   double latitude1,
                                   double longitude2,
                                   double latitude2,
                                   int width,
                                   int height,
                                   byte[][] three_state_map,
                                   boolean noCellsReturned)
determines overlap with a grid for type POLYGON when three_state_map is not null populate it with one of: GI_UNDEFINED GI_PARTIALLY_PRESENT GI_FULLY_PRESENT GI_ABSENCE

Overrides:
getOverlapGridCells in class SimpleRegion
Parameters:
longitude1 -
latitude1 -
longitude2 -
latitude2 -
xres - number of longitude segements as int
yres - number of latitude segments as int
Returns:
(x,y) as double [][2] for each grid cell at least partially falling within the specified region of the specified resolution beginning at 0,0 for minimum longitude and latitude through to xres,yres for maximums *

isWithin_EPSG900913

public boolean isWithin_EPSG900913(double longitude,
                                   double latitude)
Overrides:
isWithin_EPSG900913 in class SimpleRegion

getOverlapGridCells_EPSG900913

public int[][] getOverlapGridCells_EPSG900913(double longitude1,
                                              double latitude1,
                                              double longitude2,
                                              double latitude2,
                                              int width,
                                              int height,
                                              byte[][] three_state_map,
                                              boolean noCellsReturned)
Overrides:
getOverlapGridCells_EPSG900913 in class SimpleRegion

fillAccMask

public int[][] fillAccMask(int startPolygon,
                           int endPolygon,
                           double longitude1,
                           double latitude1,
                           double longitude2,
                           double latitude2,
                           int width,
                           int height,
                           byte[][] three_state_map,
                           boolean noCellsReturned)

fillAccMask_EPSG900913

public int[][] fillAccMask_EPSG900913(int startPolygon,
                                      int endPolygon,
                                      double longitude1,
                                      double latitude1,
                                      double longitude2,
                                      double latitude2,
                                      int width,
                                      int height,
                                      byte[][] three_state_map,
                                      boolean noCellsReturned)


Copyright © 2014. All Rights Reserved.