com.mizar.geometry
Class Point

java.lang.Object
  extended by com.mizar.geometry.Geometry
      extended by com.mizar.geometry.Point
All Implemented Interfaces:
ZeroCell, java.lang.Comparable

public class Point
extends Geometry
implements ZeroCell, java.lang.Comparable


Nested Class Summary
 
Nested classes/interfaces inherited from class com.mizar.geometry.Geometry
Geometry.Results
 
Field Summary
 
Fields inherited from class com.mizar.geometry.Geometry
defaultOrdinates, dimensions, geographic, LEFTSIDE, maximumCoordinates, mbr, minimumCoordinates, ONLINE, ordinates, precision, results, RIGHTSIDE, SIDE, toStringDecimals
 
Constructor Summary
Point()
           
Point(double precision)
           
Point(double[] ordinates)
           
Point(double[] ordinates, double precision)
           
Point(double[] ordinates, int dimensions)
           
Point(double[] ordinates, int dimensions, double precision)
           
Point(double x, double y)
           
Point(double x, double y, double z)
           
 
Method Summary
static double angle(double x0, double y0, double x1, double y1)
           
static double angle(Point origin, Point referencePoint)
           
static Point average(java.util.ArrayList<Point> points)
          Computes a simple average of points
 boolean between(double[] p1, double[] p2)
          Tests if this point lies between p1 and p2.
 boolean between(Point p1, Point p2)
           
static int compare(double[] point1, double[] point2)
           
static int compare(double[] point1, double[] point2, double precision)
           
static int compare(double x1, double y1, double x2, double y2, double precision)
           
 int compareTo(double[] point, double precision)
          Only compares the first two dimensions.
 int compareTo(java.lang.Object obj)
           
 int compareTo(Point point, double precision)
          Only compares the first two dimensions.
static Point[] createPointArray(double[] ordinates, int dimensions)
           
static Point[] createPointArray(double[] ordinates, int dimensions, double precision)
           
static double[] decodeLongKey(long key, double baseX, double baseY, int precision, long xFactor)
           
static double[] decodeStringKey(java.lang.String key, int precision)
           
static double distance(double[] point1, double[] point2, double precision)
           
static double distance(double x1, double y1, double x2, double y2, double precision)
           
static double distance(long key1, long key2, double baseX, double baseY, int precision, long xFactor)
          The method computes an orthoganal distance between to long keys If the keys are created with geographic coordinates (lat/long) see GeodesyUtils.distanceHaversine(long,long)
 double distance(Point target)
           
static double distance(Point point1, Point point2)
           
static double distance(java.lang.String key1, java.lang.String key2, int precision)
          The method computes the distance between two String keys.
static double distance3D(double[] point1, double[] point2, double precision)
           
 boolean equivalent(Point point)
          Compares two points on all properties for an exact match.
 boolean equivalent(Point point, int dimensions)
          Compares only the first dimensions ordinates of this and point
 double[] getLocation()
           
static Point getMidPoint(Point p1, Point p2)
          Creates a Point with dimensions equal to the minimum dimensions of p1 or p2 that holds the average value for each ordinate.
 double getOrdinate(int i)
          Gets specific value Point's ordinate
 java.lang.String getWKT()
           
 double getX()
           
 double getY()
           
 double magnitude()
           
static double magnitude(double[] point)
           
static void main(java.lang.String[] args)
           
static long makeLongKey(double x, double y, double baseX, double baseY, int precision, long xFactor)
          The method manufactures a long that can be converted back to the pair of doubles using decodeLongKey decodeLongKey does not always return the exact double values as given here do to floating point behavior; however it should be accurate within the precision given.
static java.lang.String makeStringKey(double x, double y, int precision)
          The method manufactures a String that can be converted back to the pair of doubles using decodeStringKey This method provides better decimal control than makeLongKey The purpose is to create scalar keys for node locations that can be stored in a database and quickly found.
 boolean nearlyEqual(Point inPoint)
          Compares two points using all dimensions within the least precise of the 2
static double[] pointAtOffsetFromLine(double[] start, double[] end, double percentageAlongLine, double distanceFromLine, java.lang.Boolean offsetFromLeft)
          Gets a point by travelling a certain percentage along a two point line then moving perpendicular from that line by a set distance on either the left or the right hand side.
 boolean similar(Point point)
          Compares two points within the precision of this Point using all dimensions
static double[] subtract(double[] ords1, double[] ords2)
           
 Point subtract(Point pt)
           
static java.util.ArrayList<Point> uniquePoints(java.util.ArrayList<OneCell> linearGeometries, double tolerance)
          Builds an ArrayList of Points that represent a node set of the endpoints of linearGeometries
 
Methods inherited from class com.mizar.geometry.Geometry
adjustEndPoints, adjustEndPoints, adjustEndPoints, adjustEndPoints, changeDimensions, computeMbr, computeMbr, computeMbr, computeNearestDistance, computeNearestDistance, connectsTo, connectsTo, connectsTo, connectsTo, constructDefaultPoint, equals, expandMbr, getCoordinate, getCoordinates, getCoordinates, getCoordinates, getCoordinates, getDefaultOrdinates, getDimensions, getEndCoordinateIndex, getFirstPoint, getFirstPoint, getLastPoint, getLastPoint, getLeastDimension, getLeastPrecise, getLength, getLength, getMaximumCoordinates, getMbr, getMbrCorner, getMbrCorner, getMinimumCoordinates, getMostPrecise, getNumberOfCoordiates, getOrdinates, getPoints, getPointWithMatchingDimensions, getPrecision, getRange, getRange, getResults, getSegment, getToStringDecimals, getXYCoordinates, getXYCoordinates, hashCode, isCoveredByMbr, isEqualOrBetween, isGeographic, isInsideMbr, isSame, mbrIntersect, mbrOverlap, mbrOverlap, mbrOverlapRatio, mbrValid, polygonizeMbr, quadrant, seedMbr, setCoordinate, setCoordinates, setCoordinates, setDefaultOrdinates, setDimensions, setFirstPoint, setGeographic, setLastPoint, setMaximumCoordinates, setMinimumCoordinates, setOrdinates, setPrecision, setSegment, setToStringDecimals, toString, updateMbr
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Point

public Point()

Point

public Point(double precision)

Point

public Point(double[] ordinates)
      throws GeometryException
Parameters:
ordinates -
Throws:
GeometryException

Point

public Point(double[] ordinates,
             int dimensions)
      throws GeometryException
Throws:
GeometryException

Point

public Point(double[] ordinates,
             double precision)
      throws GeometryException
Parameters:
ordinates -
precision -
Throws:
GeometryException

Point

public Point(double[] ordinates,
             int dimensions,
             double precision)
      throws GeometryException
Throws:
GeometryException

Point

public Point(double x,
             double y)
      throws GeometryException
Throws:
GeometryException

Point

public Point(double x,
             double y,
             double z)
      throws GeometryException
Throws:
GeometryException
Method Detail

angle

public static double angle(double x0,
                           double y0,
                           double x1,
                           double y1)

angle

public static double angle(Point origin,
                           Point referencePoint)
                    throws GeometryException
Throws:
GeometryException

getLocation

public double[] getLocation()
                     throws GeometryException
Specified by:
getLocation in interface ZeroCell
Returns:
The Point's ordinates array
Throws:
GeometryException

getX

public double getX()
            throws GeometryException
Throws:
GeometryException

getY

public double getY()
            throws GeometryException
Throws:
GeometryException

getOrdinate

public double getOrdinate(int i)
                   throws GeometryException
Gets specific value Point's ordinate

Parameters:
i. - Index position of ordinates array
Returns:
Throws:
GeometryException

getWKT

public java.lang.String getWKT()

getMidPoint

public static Point getMidPoint(Point p1,
                                Point p2)
                         throws GeometryException
Creates a Point with dimensions equal to the minimum dimensions of p1 or p2 that holds the average value for each ordinate.

Parameters:
p1 -
p2 -
Returns:
a point midway between p1 and p2
Throws:
GeometryException

distance

public double distance(Point target)

distance

public static double distance(double x1,
                              double y1,
                              double x2,
                              double y2,
                              double precision)
Parameters:
x1 -
y1 -
x2 -
y2 -
Returns:
the distance between {x1,y1} and {x2,y2}

pointAtOffsetFromLine

public static double[] pointAtOffsetFromLine(double[] start,
                                             double[] end,
                                             double percentageAlongLine,
                                             double distanceFromLine,
                                             java.lang.Boolean offsetFromLeft)
                                      throws GeometryException
Gets a point by travelling a certain percentage along a two point line then moving perpendicular from that line by a set distance on either the left or the right hand side. Useful for offsetting an address point x distance from the street used to create the point.

Parameters:
start -
end -
percentageAlongLine -
distanceFromLine -
offsetFromLeft -
Returns:
the location of the offset point as a coordinate pair
Throws:
GeometryException

distance

public static double distance(double[] point1,
                              double[] point2,
                              double precision)
Parameters:
point1 -
point2 -
Returns:
the distance between point1 and point2

distance3D

public static double distance3D(double[] point1,
                                double[] point2,
                                double precision)

distance

public static double distance(Point point1,
                              Point point2)

compareTo

public int compareTo(java.lang.Object obj)
Specified by:
compareTo in interface java.lang.Comparable

compareTo

public int compareTo(Point point,
                     double precision)
Only compares the first two dimensions. The method does an absolute comparison, it does not take precision into account.

Parameters:
point -
Returns:
-1 if less, 0 if identical, and 1 if greater than

compareTo

public int compareTo(double[] point,
                     double precision)
Only compares the first two dimensions. The method does an absolute comparison, it does not take precision into account.

Parameters:
point -
Returns:
-1 if less, 0 if identical, and 1 if greater than

compare

public static int compare(double[] point1,
                          double[] point2)
Parameters:
point1 -
point2 -
Returns:
-1 if less, 0 if identical, and 1 if greater than

compare

public static int compare(double[] point1,
                          double[] point2,
                          double precision)
Parameters:
point1 -
point2 -
precision -
Returns:
-1 if less, 0 if identical, and 1 if greater than

compare

public static int compare(double x1,
                          double y1,
                          double x2,
                          double y2,
                          double precision)
Parameters:
x1 -
y1 -
x2 -
y2 -
Returns:
-1 if less, 0 if identical, and 1 if greater than

equivalent

public boolean equivalent(Point point)
Compares two points on all properties for an exact match. The coordinate test is done within the limits of the given precision.

Parameters:
point -
Returns:
false if points do not match by dimensions, precision, or ordinates.
See Also:
similar(com.mizar.geometry.Point)

equivalent

public boolean equivalent(Point point,
                          int dimensions)
Compares only the first dimensions ordinates of this and point

Parameters:
point -
dimensions -
Returns:

similar

public boolean similar(Point point)
Compares two points within the precision of this Point using all dimensions

Parameters:
point -
Returns:
true if the same dimension, area, and the ordinates are within this.precision
See Also:
equivalent(Point)

nearlyEqual

public boolean nearlyEqual(Point inPoint)
Compares two points using all dimensions within the least precise of the 2

Parameters:
inPoint - the point to test
Returns:
true if the same dimension, area, and the ordinates are within least precise
See Also:
similar(com.mizar.geometry.Point)

between

public boolean between(double[] p1,
                       double[] p2)
                throws GeometryException
Tests if this point lies between p1 and p2. More specifically, is in the rectangle formed by p1 and p2, in no specific order.

Parameters:
p1 - first point
p2 - second point
Returns:
Throws:
GeometryException

between

public boolean between(Point p1,
                       Point p2)
                throws GeometryException
Throws:
GeometryException

magnitude

public static double magnitude(double[] point)
                        throws GeometryException
Parameters:
point -
Returns:
the area of the direction vector defined by point
Throws:
GeometryException

magnitude

public double magnitude()
                 throws GeometryException
Returns:
the area of the direction vector defined by this Point
Throws:
GeometryException

subtract

public Point subtract(Point pt)
               throws GeometryException
Throws:
GeometryException

subtract

public static double[] subtract(double[] ords1,
                                double[] ords2)
                         throws GeometryException
Throws:
GeometryException

uniquePoints

public static java.util.ArrayList<Point> uniquePoints(java.util.ArrayList<OneCell> linearGeometries,
                                                      double tolerance)
                                               throws GeometryException
Builds an ArrayList of Points that represent a node set of the endpoints of linearGeometries

Parameters:
linearGeometries -
tolerance -
Returns:
Throws:
GeometryException

average

public static Point average(java.util.ArrayList<Point> points)
                     throws GeometryException
Computes a simple average of points

Parameters:
points -
Returns:
a Point object of the least dimension of points
Throws:
GeometryException

createPointArray

public static Point[] createPointArray(double[] ordinates,
                                       int dimensions)
                                throws GeometryException
Throws:
GeometryException

createPointArray

public static Point[] createPointArray(double[] ordinates,
                                       int dimensions,
                                       double precision)
                                throws GeometryException
Throws:
GeometryException

makeStringKey

public static java.lang.String makeStringKey(double x,
                                             double y,
                                             int precision)
The method manufactures a String that can be converted back to the pair of doubles using decodeStringKey This method provides better decimal control than makeLongKey The purpose is to create scalar keys for node locations that can be stored in a database and quickly found.

Parameters:
x -
y -
precision - the number of decimal places to retain
Returns:
a radix 36 String
See Also:
decodeStringKey(java.lang.String, int)

decodeStringKey

public static double[] decodeStringKey(java.lang.String key,
                                       int precision)
Parameters:
key - a radix 36 String created with makeStringKey
precision - the number of decimal places used with makeStringKey to create the key
Returns:
an array of two doubles

makeLongKey

public static long makeLongKey(double x,
                               double y,
                               double baseX,
                               double baseY,
                               int precision,
                               long xFactor)
The method manufactures a long that can be converted back to the pair of doubles using decodeLongKey decodeLongKey does not always return the exact double values as given here do to floating point behavior; however it should be accurate within the precision given. And as the purpose is to create scalar keys for node locations that can be stored in a database and quickly found, there might be no need to ever use decodeLongKey

Parameters:
x -
y -
baseX - a number to add to x to ensure that it is always positive.
baseY - a number to add to y to ensure that it is always positive.
precision - the number of decimal places to retain
xFactor - a scale factor that is greater than the largest value of y + baseY. For example, if y ranged from -90 to +90 and baseY was 90, the xFactor should be 181.
Returns:
a scalar that you can store and compare to other similar values to determine equality.

decodeLongKey

public static double[] decodeLongKey(long key,
                                     double baseX,
                                     double baseY,
                                     int precision,
                                     long xFactor)
Parameters:
key -
baseX -
baseY -
precision -
xFactor -
Returns:

distance

public static double distance(long key1,
                              long key2,
                              double baseX,
                              double baseY,
                              int precision,
                              long xFactor)
The method computes an orthoganal distance between to long keys If the keys are created with geographic coordinates (lat/long) see GeodesyUtils.distanceHaversine(long,long)

Parameters:
key1 - a key created with Point.makeLongKey
key2 - a key created with Point.makeLongKey
baseX - the baseX used for the Point.makeLongKey calls
baseY - the baseY used for the Point.makeLongKey calls
precision - the precision used for the Point.makeLongKey calls
xFactor - the xFactor used for the Point.makeLongKey calls
Returns:
orthoganal distance in the same units as key1 and key2
See Also:
makeLongKey(double, double, double, double, int, long)

distance

public static double distance(java.lang.String key1,
                              java.lang.String key2,
                              int precision)
The method computes the distance between two String keys. If the keys are created with geographic coordinates (lat/long) see GeodesyUtils.distanceHaversine(String,String)

Parameters:
key1 - a key created with Point.makeStringKey
key2 - a key created with Point.makeStringKey
precision - the precision used for the Point.makeStringKey calls
Returns:
orthoganal distance in the same units as key1 and key2
See Also:
makeStringKey(double, double, int)

main

public static void main(java.lang.String[] args)