1757{
1764 uint32_t i, j;
1765 int use_sphere = (
s->a ==
s->b ? 1 : 0);
1766
1767
1769
1770
1772 return -1.0;
1773
1774
1776 {
1781
1783 if ( use_sphere )
1785
1786 else if (
distance < 0.95 * tolerance )
1788
1789 else
1791 }
1792
1793
1795 {
1796
1797 uint32_t i;
1800
1802 {
1803 pa_one = pa1;
1804 pa_many = pa2;
1805 }
1806 else
1807 {
1808 pa_one = pa2;
1809 pa_many = pa1;
1810 }
1811
1812
1815
1816
1819
1820
1821 for ( i = 1; i < pa_many->
npoints; i++ )
1822 {
1823 double d;
1826
1828
1830 {
1832 nearest2 = g2;
1833 }
1834
1835 if ( d <= tolerance )
1836 {
1837
1838 if ( use_sphere )
1839 {
1840 return d;
1841 }
1842
1843 else if ( d <= tolerance * 0.95 )
1844 {
1845 return d;
1846 }
1847
1848 else
1849 {
1851
1852 if ( d <= tolerance )
1853 return d;
1854 }
1855 }
1857 }
1858
1859
1860 if ( use_sphere )
1862
1863 else
1865
1866 }
1867
1868
1872
1873
1874
1875 for ( i = 1; i < pa1->
npoints; i++ )
1876 {
1880
1881
1885
1886 for ( j = 1; j < pa2->
npoints; j++ )
1887 {
1888 double d;
1889
1893
1898
1900 {
1901 LWDEBUG(4,
"edge intersection! returning 0.0");
1902 return 0.0;
1903 }
1905 LWDEBUGF(4,
"got edge_distance_to_edge %.8g", d);
1906
1908 {
1910 nearest1 = g1;
1911 nearest2 = g2;
1912 }
1913 if ( d <= tolerance )
1914 {
1915 if ( use_sphere )
1916 {
1917 return d;
1918 }
1919 else
1920 {
1922 if ( d <= tolerance )
1923 return d;
1924 }
1925 }
1926
1927
1929 B1 = B2;
1930 }
1931
1932
1934 A1 = A2;
1936 }
1938
1939 if ( use_sphere )
1941 else
1943}
#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.