Module: PostgisFunctions::PointFunctions
- Defined in:
- lib/postgis_functions/common.rb
Overview
POINT
Instance Method Summary collapse
-
#azimuth(other) ⇒ Object
The azimuth of the segment defined by the given Point geometries, or NULL if the two points are coincident.
-
#distance_sphere_to(other) ⇒ Object
Linear distance in meters between two lon/lat points.
-
#distance_spheroid_to(other, spheroid = EARTH_SPHEROID) ⇒ Object
Calculates the distance on an ellipsoid.
-
#inside_circle?(x, y, r) ⇒ Boolean
True if the geometry is a point and is inside the circle.
-
#where_on_line(line) ⇒ Object
Returns a float between 0 and 1 representing the location of the closest point on LineString to the given Point, as a fraction of total 2d line length.
Instance Method Details
#azimuth(other) ⇒ Object
The azimuth of the segment defined by the given Point geometries, or NULL if the two points are coincident. Return value is in radians.
The Azimuth is mathematical concept defined as the angle, in this case measured in radian, between a reference plane and a point.
Returns Float ST_Azimuth(geometry pointA, geometry pointB);
795 796 797 798 799 800 |
# File 'lib/postgis_functions/common.rb', line 795 def azimuth other #TODO: return if not point/point postgis_calculate(:azimuth, [self, other]).to_f rescue ActiveRecord::StatementInvalid end |
#distance_sphere_to(other) ⇒ Object
Linear distance in meters between two lon/lat points. Uses a spherical earth and radius of 6370986 meters. Faster than ‘distance_spheroid’, but less accurate.
Only implemented for points.
Returns Float ST_Distance_Sphere(geometry pointlonlatA, geometry pointlonlatB);
759 760 761 |
# File 'lib/postgis_functions/common.rb', line 759 def distance_sphere_to(other) postgis_calculate(:distance_sphere, [self, other]).to_f end |
#distance_spheroid_to(other, spheroid = EARTH_SPHEROID) ⇒ Object
Calculates the distance on an ellipsoid. This is useful if the coordinates of the geometry are in longitude/latitude and a length is desired without reprojection. The ellipsoid is a separate database type and can be constructed as follows:
This is slower then ‘distance_sphere_to’, but more precise.
SPHEROID[<NAME>,<SEMI-MAJOR AXIS>,<INVERSE FLATTENING>]
Example:
SPHEROID["GRS_1980",6378137,298.257222101]
Defaults to:
SPHEROID["IERS_2003",6378136.6,298.25642]
Returns ST_Distance_Spheroid(geometry geomA, geometry geomB, spheroid);
782 783 784 |
# File 'lib/postgis_functions/common.rb', line 782 def distance_spheroid_to(other, spheroid = EARTH_SPHEROID) postgis_calculate(:distance_spheroid, [self, other], spheroid).to_f end |
#inside_circle?(x, y, r) ⇒ Boolean
True if the geometry is a point and is inside the circle.
Returns Boolean ST_point_inside_circle(geometry, float, float, float)
807 808 809 |
# File 'lib/postgis_functions/common.rb', line 807 def inside_circle?(x,y,r) postgis_calculate(:point_inside_circle, self, [x,y,r]) end |
#where_on_line(line) ⇒ Object
Returns a float between 0 and 1 representing the location of the closest point on LineString to the given Point, as a fraction of total 2d line length.
You can use the returned location to extract a Point (ST_Line_Interpolate_Point) or a substring (ST_Line_Substring).
This is useful for approximating numbers of addresses.
Returns float (0 to 1) ST_Line_Locate_Point(geometry a_linestring, geometry a_point);
746 747 748 |
# File 'lib/postgis_functions/common.rb', line 746 def where_on_line line postgis_calculate(:line_locate_point, [line, self]).to_f end |