lib/postgis_functions/point.rb in nofxx-postgis_adapter-0.1.7 vs lib/postgis_functions/point.rb in nofxx-postgis_adapter-0.1.8

- old
+ new

@@ -7,23 +7,10 @@ # # module PointFunctions # - # True if the geometries are within the specified distance of one another. - # The distance is specified in units defined by the spatial reference system - # of the geometries. For this function to make sense, the source geometries - # must both be of the same coorindate projection, having the same SRID. - # - # Returns boolean ST_DWithin(geometry g1, geometry g2, double precision distance); - # - def d_within?(other, margin=0.1) - postgis_calculate(:dwithin, [self, other], margin) - end - alias_method "in_bounds?", "d_within?" - - # # 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). @@ -31,11 +18,11 @@ # This is useful for approximating numbers of addresses. # # Returns float (0 to 1) ST_Line_Locate_Point(geometry a_linestring, geometry a_point); # def where_on_line line - postgis_calculate(:line_locate_point, [line, self]) + postgis_calculate(:line_locate_point, [line, self]).to_f end # # Linear distance in meters between two lon/lat points. # Uses a spherical earth and radius of 6370986 meters. @@ -44,11 +31,11 @@ # Only implemented for points. # # Returns Float ST_Distance_Sphere(geometry pointlonlatA, geometry pointlonlatB); # def distance_sphere_to(other) - dis = postgis_calculate(:distance_sphere, [self, other]) + dis = postgis_calculate(:distance_sphere, [self, other]).to_f end # # Calculates the distance on an ellipsoid. This is useful if the # coordinates of the geometry are in longitude/latitude and a length is @@ -67,11 +54,11 @@ # SPHEROID["IERS_2003",6378136.6,298.25642] # # Returns ST_Distance_Spheroid(geometry geomA, geometry geomB, spheroid); # def distance_spheroid_to(other, spheroid = EARTH_SPHEROID) - postgis_calculate(:distance_spheroid, [self, other], spheroid) + postgis_calculate(:distance_spheroid, [self, other], spheroid).to_f end # # The azimuth of the segment defined by the given Point geometries, # or NULL if the two points are coincident. Return value is in radians. @@ -81,10 +68,10 @@ # # Returns Float ST_Azimuth(geometry pointA, geometry pointB); # def azimuth other #TODO: return if not point/point - postgis_calculate(:azimuth, [self, other]) + postgis_calculate(:azimuth, [self, other]).to_f rescue ActiveRecord::StatementInvalid end # \ No newline at end of file