diff -N -c -r --exclude=CVS earth.old/README.earthdistance earthdistance/README.earthdistance *** earth.old/README.earthdistance Sat Jan 25 22:39:38 2003 --- earthdistance/README.earthdistance Sat Jan 25 23:29:59 2003 *************** *** 39,63 **** The functions are all 'sql' functions. If you want to make these functions executable by other people you will also have to make the referenced ! cube functions executable. cube(text), cube_distance(cube,cube), ! cube_ll_coord(cube,int) and cube_enlarge(cube,float8,int) are used indirectly ! by the earth distance functions. is_point(cube) and cube_dim(cube) are used ! in suggested constraints for data in domain earth. cube_ur_coord(cube,int) ! is used in the regression tests and might be useful for looking at bounding ! box coordinates in user applications. ! ! A domain of type cube named earth is defined. Since check constraints ! are not supported for domains yet, this isn't as useful as it might be. ! However the checks that should be supplied to all data of type earth are: ! ! constraint not_point check(is_point(earth)) ! constraint not_3d check(cube_dim(earth) <= 3) ! constraint on_surface check(abs(cube_distance(earth, '(0)'::cube) / ! earth() - 1) < '10e-12'::float8); The following functions are provided: ! earth() - Returns the radius of the earth in meters. sec_to_gc(float8) - Converts the normal straight line (secant) distance between between two points on the surface of the Earth to the great circle distance --- 39,60 ---- The functions are all 'sql' functions. If you want to make these functions executable by other people you will also have to make the referenced ! cube functions executable. cube(text), cube(float8), cube(cube,float8), ! cube_distance(cube,cube), cube_ll_coord(cube,int) and ! cube_enlarge(cube,float8,int) are used indirectly by the earth distance ! functions. is_point(cube) and cube_dim(cube) are used in constraints for data ! in domain earth. cube_ur_coord(cube,int) is used in the regression tests and ! might be useful for looking at bounding box coordinates in user applications. ! ! A domain of type cube named earth is defined. ! There are constraints on it defined to make sure the cube is a point, ! that it does not have more than 3 dimensions and that it is very near ! the surface of a sphere centered about the origin with the radius of ! the Earth. The following functions are provided: ! earth() - Returns the radius of the Earth in meters. sec_to_gc(float8) - Converts the normal straight line (secant) distance between between two points on the surface of the Earth to the great circle distance *************** *** 118,124 **** > look at to create these? Here's the setup for adding an operator '<@>' to give distance in ! statute miles between two points on the earth's surface. Coordinates are in degrees. Points are taken as (longitude, latitude) and not vice versa as longitude is closer to the intuitive idea of x-axis and latitude to y-axis. --- 115,121 ---- > look at to create these? Here's the setup for adding an operator '<@>' to give distance in ! statute miles between two points on the Earth's surface. Coordinates are in degrees. Points are taken as (longitude, latitude) and not vice versa as longitude is closer to the intuitive idea of x-axis and latitude to y-axis. diff -N -c -r --exclude=CVS earth.old/earthdistance.sql.in earthdistance/earthdistance.sql.in *** earth.old/earthdistance.sql.in Sat Jan 25 22:39:38 2003 --- earthdistance/earthdistance.sql.in Sat Jan 25 23:24:54 2003 *************** *** 24,36 **** -- Define domain for locations on the surface of the earth using a cube -- datatype with constraints. cube provides 3D indexing. ! -- Check constraints aren't currently supported. ! CREATE DOMAIN earth AS cube; ! -- CONSTRAINT not_point check(is_point(earth)) ! -- CONSTRAINT not_3d check(cube_dim(earth) <= 3) ! -- CONSTRAINT on_surface check(abs(cube_distance(earth, '(0)'::cube) / ! -- earth() - 1) < '10e-12'::float8); CREATE OR REPLACE FUNCTION sec_to_gc(float8) RETURNS float8 --- 24,39 ---- -- Define domain for locations on the surface of the earth using a cube -- datatype with constraints. cube provides 3D indexing. ! -- The cube is restricted to be a point, no more than 3 dimensions ! -- (for less than 3 dimensions 0 is assumed for the missing coordinates) ! -- and that the point must be very near the surface of the sphere ! -- centered about the origin with the radius of the earth. ! CREATE DOMAIN earth AS cube ! CONSTRAINT not_point check(cube_is_point(value)) ! CONSTRAINT not_3d check(cube_dim(value) <= 3) ! CONSTRAINT on_surface check(abs(cube_distance(value, '(0)'::cube) / ! earth() - 1) < '10e-7'::float8); CREATE OR REPLACE FUNCTION sec_to_gc(float8) RETURNS float8 *************** *** 48,54 **** RETURNS earth LANGUAGE 'sql' IMMUTABLE STRICT ! AS 'SELECT cube(\'(\'||earth()*cos(radians($1))*cos(radians($2))||\',\'||earth()*cos(radians($1))*sin(radians($2))||\',\'||earth()*sin(radians($1))||\')\')'; CREATE OR REPLACE FUNCTION latitude(earth) RETURNS float8 --- 51,57 ---- RETURNS earth LANGUAGE 'sql' IMMUTABLE STRICT ! AS 'SELECT cube(cube(cube(earth()*cos(radians($1))*cos(radians($2))),earth()*cos(radians($1))*sin(radians($2))),earth()*sin(radians($1)))'; CREATE OR REPLACE FUNCTION latitude(earth) RETURNS float8