Sunteți pe pagina 1din 2

PostGIS 1.5.

1 Manual
188 / 315

7.8.16 ST_Distance_Spheroid
Name
ST_Distance_Spheroid Returns the minimum distance between two lon/lat geometries given a particular spheroid. PostGIS
versions prior to 1.5 only support points.

Synopsis
float ST_Distance_Spheroid(geometry geomlonlatA, geometry geomlonlatB, spheroid measurement_spheroid);

Description
Returns minimum distance in meters between two lon/lat geometries given a particular spheroid. See the explanation of spheroids
given for ST_Length_Spheroid. PostGIS version prior to 1.5 only support points.

Note
This function currently does not look at the SRID of a geometry and will always assume its in WGS 80 long lat. Prior
versions of this function only support points.

Availability: 1.5 - support for other geometry types besides points was introduced. Prior versions only work with points.

Examples
SELECT round(CAST(
ST_Distance_Spheroid(ST_Centroid(the_geom), ST_GeomFromText(POINT(-118 38),4326), SPHEROID["WGS 84",6378137,298.257223563])
As numeric),2) As dist_meters_spheroid,
round(CAST(ST_Distance_Sphere(ST_Centroid(the_geom), ST_GeomFromText(POINT(-118 38) ,4326)) As numeric),2) As dist_meters_sphere,
round(CAST(ST_Distance(ST_Transform(ST_Centroid(the_geom),32611),
ST_Transform(ST_GeomFromText(POINT(-118 38), 4326),32611)) As numeric),2) As dist_utm11_meters
FROM
(SELECT ST_GeomFromText(LINESTRING(-118.584 38.374,-118.583 38.5), 4326) As the_geom) as foo;
dist_meters_spheroid | dist_meters_sphere | dist_utm11_meters
----------------------+--------------------+------------------70454.92 |
70424.47 |
70438.00

See Also
ST_Distance, ST_Distance_Sphere

7.8.17 ST_DFullyWithin
Name
ST_DFullyWithin Returns true if all of the geometries are within the specified distance of one another

PostGIS 1.5.1 Manual


189 / 315

Synopsis
boolean ST_DFullyWithin(geometry g1, geometry g2, double precision distance);

Description
Returns true if the geometries is fully 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
coordinate projection, having the same SRID.

Note
This function call will automatically include a bounding box comparison that will make use of any indexes that are
available on the geometries.

Availability: 1.5.0

Examples
postgis=# SELECT ST_DFullyWithin(geom_a, geom_b, 10) as DFullyWithin10, ST_DWithin(geom_a, geom_b, 10) as DWithin10, ST_DFullyWithin(geom_a, geom_b, 20) as DFullyWithin20 from
(select ST_GeomFromText(POINT(1 1)) as geom_a,ST_GeomFromText(LINESTRING(1 5, 2 7, 1 9, 14 12)) as geom_b) t1;
----------------DFullyWithin10 | DWithin10 | DFullyWithin20 |
---------------+----------+---------------+
f
| t
| t
|

See Also
ST_MaxDistance, ST_DWithin

7.8.18 ST_DWithin
Name
ST_DWithin Returns true if the geometries are within the specified distance of one another. For geometry units are in those
of spatial reference and For geography units are in meters and measurement is defaulted to use_spheroid=true (measure around
spheroid), for faster check, use_spheroid=false to measure along sphere.

Synopsis
boolean ST_DWithin(geometry g1, geometry g2, double precision distance_of_srid);
boolean ST_DWithin(geography gg1, geography gg2, double precision distance_meters);
boolean ST_DWithin(geography gg1, geography gg2, double precision distance_meters, boolean use_spheroid);

S-ar putea să vă placă și