1836{
1843 uint32_t i, j;
1844 int use_sphere = (
s->a ==
s->b ? 1 : 0);
1845
1846
1848
1849
1851 return -1.0;
1852
1853
1855 {
1860
1862 if ( use_sphere )
1864
1865 else if (
distance < 0.95 * tolerance )
1867
1868 else
1870 }
1871
1872
1874 {
1875
1876 uint32_t i;
1879
1881 {
1882 pa_one = pa1;
1883 pa_many = pa2;
1884 }
1885 else
1886 {
1887 pa_one = pa2;
1888 pa_many = pa1;
1889 }
1890
1891
1894
1895
1898
1899
1900 for ( i = 1; i < pa_many->
npoints; i++ )
1901 {
1902 double d;
1905
1907
1909 {
1911 nearest2 = g2;
1912 }
1913
1914 if ( d < tolerance )
1915 {
1916
1917 if ( use_sphere )
1918 {
1919 return d;
1920 }
1921
1922 else if ( d < tolerance * 0.95 )
1923 {
1924 return d;
1925 }
1926
1927 else
1928 {
1930
1931 if ( d < tolerance )
1932 return d;
1933 }
1934 }
1936 }
1937
1938
1939 if ( use_sphere )
1941
1942 else
1944
1945 }
1946
1947
1951
1952
1953
1954 for ( i = 1; i < pa1->
npoints; i++ )
1955 {
1959
1960
1964
1965 for ( j = 1; j < pa2->
npoints; j++ )
1966 {
1967 double d;
1968
1972
1977
1979 {
1980 LWDEBUG(4,
"edge intersection! returning 0.0");
1981 return 0.0;
1982 }
1984 LWDEBUGF(4,
"got edge_distance_to_edge %.8g", d);
1985
1987 {
1989 nearest1 = g1;
1990 nearest2 = g2;
1991 }
1992 if ( d < tolerance )
1993 {
1994 if ( use_sphere )
1995 {
1996 return d;
1997 }
1998 else
1999 {
2001 if ( d < tolerance )
2002 return d;
2003 }
2004 }
2005
2006
2008 B1 = B2;
2009 }
2010
2011
2013 A1 = A2;
2015 }
2017
2018 if ( use_sphere )
2020 else
2022}
#define LW_ON_INTERRUPT(x)
void geographic_point_init(double lon, double lat, GEOGRAPHIC_POINT *g)
Initialize a geographic point.
double sphere_distance(const GEOGRAPHIC_POINT *s, const GEOGRAPHIC_POINT *e)
Given two points on a unit sphere, calculate their distance apart in radians.
uint32_t edge_intersects(const POINT3D *A1, const POINT3D *A2, const POINT3D *B1, const POINT3D *B2)
Returns non-zero if edges A and B interact.
double edge_distance_to_point(const GEOGRAPHIC_EDGE *e, const GEOGRAPHIC_POINT *gp, GEOGRAPHIC_POINT *closest)
void geog2cart(const GEOGRAPHIC_POINT *g, POINT3D *p)
Convert spherical coordinates to cartesian coordinates on unit sphere.
double edge_distance_to_edge(const GEOGRAPHIC_EDGE *e1, const GEOGRAPHIC_EDGE *e2, GEOGRAPHIC_POINT *closest1, GEOGRAPHIC_POINT *closest2)
Calculate the distance between two edges.
double spheroid_distance(const GEOGRAPHIC_POINT *a, const GEOGRAPHIC_POINT *b, const SPHEROID *spheroid)
Computes the shortest distance along the surface of the spheroid between two points,...
#define LWDEBUG(level, msg)
#define LWDEBUGF(level, msg,...)
static const POINT2D * getPoint2d_cp(const POINTARRAY *pa, uint32_t n)
Returns a POINT2D pointer into the POINTARRAY serialized_ptlist, suitable for reading from.
static double distance(double x1, double y1, double x2, double y2)
Two-point great circle segment from a to b.
Point in spherical coordinates on the world.