org.ala.layers.intersect
Class SimpleRegion

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

public class SimpleRegion
extends java.lang.Object
implements java.io.Serializable

SimpleRegion enables point to shape intersections, where the shape is stored within SimpleRegion as a circle, bounding box or polygon. Other utilities include shape presence on a defined grid; fully present, partially present, absent.

Author:
Adam Collins
See Also:
Serialized Form

Field Summary
static int BOUNDING_BOX
          shape type bounding box; upper, lower, left, right
static int CIRCLE
          shape type circle; point and radius
static int GI_ABSENCE
          ABSENCE state for grid intersection output
static int GI_FULLY_PRESENT
          FULLY PRESENT state for grid intersection output
static int GI_PARTIALLY_PRESENT
          PARTiALLy PRESENT state for grid intersection output
static int GI_UNDEFINED
          UNDEFINED state for grid intersection output can be considered ABSENCE
static int POLYGON
          shape type polygon; list of points as longitude, latitude pairs last point == first point
static int UNDEFINED
          shape type not declared
 
Constructor Summary
SimpleRegion()
          Constructor for a SimpleRegion with no shape
 
Method Summary
 int convertLatToPixel(double lat)
           
 int convertLngToPixel(double lng)
           
 double convertMetersToLat(double meters)
           
 double convertMetersToLng(double meters)
           
 double convertMetersToPixels(double meters, double latitude, int zoom)
           
 double convertPixelsToMeters(int pixels, double latitude, int zoom)
           
 double convertPixelToLat(int px)
           
 double convertPixelToLng(int px)
           
 int[][] fillAccMask_EPSG900913(double longitude1, double latitude1, double longitude2, double latitude2, int width, int height, byte[][] three_state_map, boolean noCellsReturned)
           
 int[][] fillAccMask(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 types POLYGON and BOUNDING_BOX
 double getHeight()
           
 int getNumberOfPoints()
          gets number of points for type POLYGON note: first point = last point
 void getOverlapGridCells_Acc_EPSG900913(double longitude1, double latitude1, double longitude2, double latitude2, int width, int height, byte[][] three_state_map)
          stacks PARTIALLY_PRESENT shape outline onto three_state_map
 void getOverlapGridCells_Acc(double longitude1, double latitude1, double longitude2, double latitude2, int width, int height, byte[][] three_state_map)
          stacks PARTIALLY_PRESENT shape outline onto three_state_map
 int[][] getOverlapGridCells_Box(double longitude1, double latitude1, double longitude2, double latitude2, int width, int height, double[][] bb, byte[][] three_state_map, boolean noCellsReturned)
          determines overlap with a grid for a BOUNDING_BOX
 int[][] getOverlapGridCells_EPSG900913(double longitude1, double latitude1, double longitude2, double latitude2, int width, int height, byte[][] three_state_map)
           
 int[][] getOverlapGridCells_EPSG900913(double longitude1, double latitude1, double longitude2, double latitude2, int width, int height, byte[][] three_state_map, boolean noCellsReturned)
           
 void getOverlapGridCells_Polygon_Acc_EPSG900913(double olongitude1, double olatitude1, double olongitude2, double olatitude2, int owidth, int oheight, byte[][] three_state_map)
           
 void getOverlapGridCells_Polygon_Acc(double longitude1, double latitude1, double longitude2, double latitude2, int width, int height, byte[][] three_state_map)
           
 int[][] getOverlapGridCells_Polygon_EPSG900913(double olongitude1, double olatitude1, double olongitude2, double olatitude2, int owidth, int oheight, byte[][] three_state_map, boolean noCellsReturned)
           
 int[][] getOverlapGridCells_Polygon(double longitude1, double latitude1, double longitude2, double latitude2, int width, int height, byte[][] three_state_map, boolean noCellsReturned)
          determines overlap with a grid for POLYGON when three_state_map is not null populate it with one of: GI_UNDEFINED GI_PARTIALLY_PRESENT GI_FULLY_PRESENT GI_ABSENCE 1.
 int[][] getOverlapGridCells(double longitude1, double latitude1, double longitude2, double latitude2, int width, int height, byte[][] three_state_map)
           
 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 getType()
           
 double getWidth()
           
 boolean isWithin_EPSG900913(double longitude, double latitude)
           
 boolean isWithin(double longitude, double latitude)
          returns true when the point provided is within the SimpleRegion note: type UNDEFINED implies no boundary, always returns true.
static SimpleRegion parseSimpleRegion(java.lang.String pointsString)
          defines a region by a points string, POLYGON only TODO: define better format for parsing, including BOUNDING_BOX and CIRCLE
 void saveGridAsImage(byte[][] three_state_map)
           
 void setBox(double longitude1, double latitude1, double longitude2, double latitude2)
          defines the SimpleRegion as type BOUNDING_BOX
 void setCircle(double longitude, double latitude, double radius_)
          defines the SimpleRegion as type CIRCLE
 void setNone()
          defines the SimpleRegion as type UNDEFINED
 void setPolygon(double[] points_)
          defines the SimpleRegion as type POLYGON
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

UNDEFINED

public static final int UNDEFINED
shape type not declared

See Also:
Constant Field Values

BOUNDING_BOX

public static final int BOUNDING_BOX
shape type bounding box; upper, lower, left, right

See Also:
Constant Field Values

CIRCLE

public static final int CIRCLE
shape type circle; point and radius

See Also:
Constant Field Values

POLYGON

public static final int POLYGON
shape type polygon; list of points as longitude, latitude pairs last point == first point

See Also:
Constant Field Values

GI_UNDEFINED

public static final int GI_UNDEFINED
UNDEFINED state for grid intersection output can be considered ABSENCE

See Also:
Constant Field Values

GI_PARTIALLY_PRESENT

public static final int GI_PARTIALLY_PRESENT
PARTiALLy PRESENT state for grid intersection output

See Also:
Constant Field Values

GI_FULLY_PRESENT

public static final int GI_FULLY_PRESENT
FULLY PRESENT state for grid intersection output

See Also:
Constant Field Values

GI_ABSENCE

public static final int GI_ABSENCE
ABSENCE state for grid intersection output

See Also:
Constant Field Values
Constructor Detail

SimpleRegion

public SimpleRegion()
Constructor for a SimpleRegion with no shape

Method Detail

getNumberOfPoints

public int getNumberOfPoints()
gets number of points for type POLYGON note: first point = last point

Returns:
number of points as int

getBoundingBox

public double[][] getBoundingBox()
gets the bounding box for types POLYGON and BOUNDING_BOX

Returns:
bounding box as double[2][2] with [][0] longitude and [][1] latitude minimum values at [0][], maximum values at [1][0]

setBox

public void setBox(double longitude1,
                   double latitude1,
                   double longitude2,
                   double latitude2)
defines the SimpleRegion as type BOUNDING_BOX

Parameters:
longitude1 -
latitude1 -
longitude2 -
latitude2 -

setNone

public void setNone()
defines the SimpleRegion as type UNDEFINED


setCircle

public void setCircle(double longitude,
                      double latitude,
                      double radius_)
defines the SimpleRegion as type CIRCLE

Parameters:
longitude -
latitude -
radius_ - radius of the circle in m

setPolygon

public void setPolygon(double[] points_)
defines the SimpleRegion as type POLYGON

Parameters:
points_ - array of points as longitude and latiude in double [n][2] where n is the number of points

isWithin

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

Parameters:
longitude -
latitude -
Returns:
true iff point is within or on the edge of this SimpleRegion

isWithin_EPSG900913

public boolean isWithin_EPSG900913(double longitude,
                                   double latitude)

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

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

getOverlapGridCells_Acc

public void getOverlapGridCells_Acc(double longitude1,
                                    double latitude1,
                                    double longitude2,
                                    double latitude2,
                                    int width,
                                    int height,
                                    byte[][] three_state_map)
stacks PARTIALLY_PRESENT shape outline onto three_state_map

Parameters:
longitude1 -
latitude1 -
longitude2 -
latitude2 -
width -
height -
three_state_map -
noCellsReturned -

getOverlapGridCells

public int[][] getOverlapGridCells(double longitude1,
                                   double latitude1,
                                   double longitude2,
                                   double latitude2,
                                   int width,
                                   int height,
                                   byte[][] three_state_map)

getOverlapGridCells_Box

public int[][] getOverlapGridCells_Box(double longitude1,
                                       double latitude1,
                                       double longitude2,
                                       double latitude2,
                                       int width,
                                       int height,
                                       double[][] bb,
                                       byte[][] three_state_map,
                                       boolean noCellsReturned)
determines overlap with a grid for a BOUNDING_BOX

Parameters:
longitude1 -
latitude1 -
longitude2 -
latitude2 -
xres - number of longitude segements as int
yres - number of latitude segments as int
bb - bounding box as double[2][2] with [][0] as longitude, [][1] as latitude, [0][] as minimum values, [1][] as maximum values
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

parseSimpleRegion

public static SimpleRegion parseSimpleRegion(java.lang.String pointsString)
defines a region by a points string, POLYGON only TODO: define better format for parsing, including BOUNDING_BOX and CIRCLE

Parameters:
pointsString - points separated by ',' with longitude and latitude separated by ':'
Returns:
SimpleRegion object

getWidth

public double getWidth()

getHeight

public double getHeight()

getType

public int getType()

saveGridAsImage

public void saveGridAsImage(byte[][] three_state_map)

getOverlapGridCells_Polygon

public int[][] getOverlapGridCells_Polygon(double longitude1,
                                           double latitude1,
                                           double longitude2,
                                           double latitude2,
                                           int width,
                                           int height,
                                           byte[][] three_state_map,
                                           boolean noCellsReturned)
determines overlap with a grid for POLYGON when three_state_map is not null populate it with one of: GI_UNDEFINED GI_PARTIALLY_PRESENT GI_FULLY_PRESENT GI_ABSENCE 1. Get 3state mask and fill edge passes as 'partial'. then 3. Test 0,0 then progress across vert raster until finding cells[][] entry 4. Repeat from (3).

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

getOverlapGridCells_Polygon_Acc

public void getOverlapGridCells_Polygon_Acc(double longitude1,
                                            double latitude1,
                                            double longitude2,
                                            double latitude2,
                                            int width,
                                            int height,
                                            byte[][] three_state_map)

fillAccMask

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

getOverlapGridCells_EPSG900913

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

getOverlapGridCells_Acc_EPSG900913

public void getOverlapGridCells_Acc_EPSG900913(double longitude1,
                                               double latitude1,
                                               double longitude2,
                                               double latitude2,
                                               int width,
                                               int height,
                                               byte[][] three_state_map)
stacks PARTIALLY_PRESENT shape outline onto three_state_map

Parameters:
longitude1 -
latitude1 -
longitude2 -
latitude2 -
width -
height -
three_state_map -
noCellsReturned -

getOverlapGridCells_EPSG900913

public int[][] getOverlapGridCells_EPSG900913(double longitude1,
                                              double latitude1,
                                              double longitude2,
                                              double latitude2,
                                              int width,
                                              int height,
                                              byte[][] three_state_map)

getOverlapGridCells_Polygon_EPSG900913

public int[][] getOverlapGridCells_Polygon_EPSG900913(double olongitude1,
                                                      double olatitude1,
                                                      double olongitude2,
                                                      double olatitude2,
                                                      int owidth,
                                                      int oheight,
                                                      byte[][] three_state_map,
                                                      boolean noCellsReturned)

getOverlapGridCells_Polygon_Acc_EPSG900913

public void getOverlapGridCells_Polygon_Acc_EPSG900913(double olongitude1,
                                                       double olatitude1,
                                                       double olongitude2,
                                                       double olatitude2,
                                                       int owidth,
                                                       int oheight,
                                                       byte[][] three_state_map)

fillAccMask_EPSG900913

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

convertLngToPixel

public int convertLngToPixel(double lng)

convertPixelToLng

public double convertPixelToLng(int px)

convertLatToPixel

public int convertLatToPixel(double lat)

convertPixelToLat

public double convertPixelToLat(int px)

convertMetersToPixels

public double convertMetersToPixels(double meters,
                                    double latitude,
                                    int zoom)

convertPixelsToMeters

public double convertPixelsToMeters(int pixels,
                                    double latitude,
                                    int zoom)

convertMetersToLng

public double convertMetersToLng(double meters)

convertMetersToLat

public double convertMetersToLat(double meters)


Copyright © 2014. All Rights Reserved.