Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitba24afb

Browse files
committed
Fix code formatting
1 parentb7152a2 commitba24afb

File tree

3 files changed

+197
-96
lines changed

3 files changed

+197
-96
lines changed

‎doc/indices.sgm

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,9 @@
6969
</listitem>
7070
</itemizedlist>
7171
<para>
72-
GiST index can beusedalso forfast finding points closest to the given one
73-
when ordering by an expression with the <literal>&lt;-&gt;</literal> operator
74-
is used,as shown in an example below.
72+
GiST index can be alsousedforquickly findingthepoints closest to the given one
73+
when ordering by an expression with the <literal>&lt;-&gt;</literal> operator,
74+
as shown in an example below.
7575
</para>
7676
<para>
7777
BRIN indexing supports just spherical points (<type>spoint</type>)
@@ -112,6 +112,7 @@
112112
<![CDATA[CREATE INDEX test_pos_idx USING BRIN ON test (pos) WITH (pages_per_range = 16);]]>
113113
</programlisting>
114114
</example>
115+
115116
</sect1>
116117

117118
<sect1 id="ind.smoc">

‎pgs_gist.sql.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ CREATE OPERATOR CLASS spoint
117117
OPERATOR 14 @ (spoint, spoly),
118118
OPERATOR 15 @ (spoint, sellipse),
119119
OPERATOR 16 @ (spoint, sbox),
120-
OPERATOR 17<-> (spoint, spoint) FOR ORDER BY float_ops,
120+
OPERATOR 17<-> (spoint, spoint) FOR ORDER BY float_ops,
121121
OPERATOR 37 <@ (spoint, scircle),
122122
OPERATOR 38 <@ (spoint, sline),
123123
OPERATOR 39 <@ (spoint, spath),

‎src/gist.c

Lines changed: 192 additions & 92 deletions
Original file line numberDiff line numberDiff line change
@@ -511,7 +511,7 @@ g_spoint_consistent(PG_FUNCTION_ARGS)
511511
SCK_INTERLEAVE(SELLIPSE,sphereellipse_gen_key,0);
512512
break;
513513
case42:
514-
SCK_INTERLEAVE(SBOX,spherebox_gen_key,0);
514+
SCK_INTERLEAVE(SBOX,spherebox_gen_key,0);
515515
break;
516516
}
517517

@@ -682,8 +682,11 @@ g_spoint3_consistent(PG_FUNCTION_ARGS)
682682
PG_RETURN_BOOL(false);
683683
}
684684

685-
staticdoubledistance_vector_point_3d (Vector3D*v,doublex,doubley,doublez) {
686-
returnacos ( (v->x*x+v->y*y+v->z*z) /sqrt(x*x+y*y+z*z ) );// as v has length=1 by design
685+
staticdouble
686+
distance_vector_point_3d(Vector3D*v,doublex,doubley,doublez)
687+
{
688+
/* as v has length = 1 by design */
689+
returnacos((v->x*x+v->y*y+v->z*z) /sqrt(x*x+y*y+z*z));
687690
}
688691

689692
Datum
@@ -1683,121 +1686,218 @@ g_spoint_distance(PG_FUNCTION_ARGS)
16831686
{
16841687
GISTENTRY*entry= (GISTENTRY*)PG_GETARG_POINTER(0);
16851688
StrategyNumberstrategy= (StrategyNumber)PG_GETARG_UINT16(2);
1686-
Box3D*box= (Box3D*)DatumGetPointer(entry->key);
1689+
Box3D*box= (Box3D*)DatumGetPointer(entry->key);
16871690
doubleretval;
16881691
SPoint*point= (SPoint*)PG_GETARG_POINTER(1);
1689-
Vector3Dv_point,v_low,v_high;
1692+
Vector3Dv_point,
1693+
v_low,
1694+
v_high;
16901695

16911696
switch (strategy)
16921697
{
16931698
case17:
1694-
// Prepare data for calculation
1699+
/* Prepare data for calculation */
16951700
spoint_vector3d(&v_point,point);
1696-
v_low.x= (double)box->low.coord[0] /MAXCVALUE;
1697-
v_low.y= (double)box->low.coord[1] /MAXCVALUE;
1698-
v_low.z= (double)box->low.coord[2] /MAXCVALUE;
1699-
v_high.x= (double)box->high.coord[0] /MAXCVALUE;
1700-
v_high.y= (double)box->high.coord[1] /MAXCVALUE;
1701-
v_high.z= (double)box->high.coord[2] /MAXCVALUE;
1702-
// a box splits space into 27 subspaces (6+12+8+1) with different distance calculation
1703-
if(v_point.x<v_low.x) {
1704-
if(v_point.y<v_low.y) {
1705-
if(v_point.z<v_low.z) {
1706-
retval=distance_vector_point_3d (&v_point,v_low.x,v_low.y,v_low.z);//point2point distance
1707-
}elseif (v_point.z<v_high.z) {
1708-
retval=distance_vector_point_3d (&v_point,v_low.x,v_low.y,v_point.z);//point2line distance
1709-
}else {
1710-
retval=distance_vector_point_3d (&v_point,v_low.x,v_low.y,v_high.z);//point2point distance
1711-
}
1712-
}elseif(v_point.y<v_high.y) {
1713-
if(v_point.z<v_low.z) {
1714-
retval=distance_vector_point_3d (&v_point,v_low.x,v_point.y ,v_low.z);//point2line distance
1715-
}elseif (v_point.z<v_high.z) {
1716-
retval=distance_vector_point_3d (&v_point,v_low.x,v_point.y ,v_point.z);//point2plane distance
1717-
}else {
1718-
retval=distance_vector_point_3d (&v_point,v_low.x,v_point.y,v_high.z);//point2line distance
1701+
v_low.x= (double)box->low.coord[0] /MAXCVALUE;
1702+
v_low.y= (double)box->low.coord[1] /MAXCVALUE;
1703+
v_low.z= (double)box->low.coord[2] /MAXCVALUE;
1704+
v_high.x= (double)box->high.coord[0] /MAXCVALUE;
1705+
v_high.y= (double)box->high.coord[1] /MAXCVALUE;
1706+
v_high.z= (double)box->high.coord[2] /MAXCVALUE;
1707+
1708+
/*
1709+
* a box splits space into 27 subspaces (6+12+8+1) with different
1710+
* distance calculation
1711+
*/
1712+
if (v_point.x<v_low.x)
1713+
{
1714+
if (v_point.y<v_low.y)
1715+
{
1716+
if (v_point.z<v_low.z)
1717+
{
1718+
/* point2point distance */
1719+
retval=distance_vector_point_3d(&v_point,v_low.x,v_low.y,v_low.z);
1720+
}
1721+
elseif (v_point.z<v_high.z)
1722+
{
1723+
/* point2line distance */
1724+
retval=distance_vector_point_3d(&v_point,v_low.x,v_low.y,v_point.z);
1725+
}
1726+
else
1727+
{
1728+
/* point2point distance */
1729+
retval=distance_vector_point_3d(&v_point,v_low.x,v_low.y,v_high.z);
1730+
}
1731+
}
1732+
elseif (v_point.y<v_high.y)
1733+
{
1734+
if (v_point.z<v_low.z)
1735+
{
1736+
/* point2line distance */
1737+
retval=distance_vector_point_3d(&v_point,v_low.x,v_point.y,v_low.z);
1738+
}
1739+
elseif (v_point.z<v_high.z)
1740+
{
1741+
/* point2plane distance */
1742+
retval=distance_vector_point_3d(&v_point,v_low.x,v_point.y,v_point.z);
1743+
}
1744+
else
1745+
{
1746+
/* point2line distance */
1747+
retval=distance_vector_point_3d(&v_point,v_low.x,v_point.y,v_high.z);
1748+
}
1749+
}
1750+
else
1751+
{
1752+
if (v_point.z<v_low.z)
1753+
{
1754+
/* point2point distance */
1755+
retval=distance_vector_point_3d(&v_point,v_low.x,v_high.y,v_low.z);
1756+
}
1757+
elseif (v_point.z<v_high.z)
1758+
{
1759+
/* point2line distance */
1760+
retval=distance_vector_point_3d(&v_point,v_low.x,v_high.y,v_point.z);
1761+
}
1762+
else
1763+
{
1764+
/* point2point distance */
1765+
retval=distance_vector_point_3d(&v_point,v_low.x,v_high.y,v_high.z);
1766+
}
1767+
}
1768+
}
1769+
elseif (v_point.x<v_high.x)
1770+
{
1771+
if (v_point.y<v_low.y)
1772+
{
1773+
if (v_point.z<v_low.z)
1774+
{
1775+
/* p2line distance */
1776+
retval=distance_vector_point_3d(&v_point,v_point.x,v_low.y,v_low.z);
1777+
}
1778+
elseif (v_point.z<v_high.z)
1779+
{
1780+
/* point2plane distance */
1781+
retval=distance_vector_point_3d(&v_point,v_point.x,v_low.y,v_point.z);
1782+
}
1783+
else
1784+
{
1785+
/* point2line distance */
1786+
retval=distance_vector_point_3d(&v_point,v_point.x,v_low.y,v_high.z);
17191787
}
1720-
}else {
1721-
if(v_point.z<v_low.z) {
1722-
retval=distance_vector_point_3d (&v_point,v_low.x,v_high.y,v_low.z);//point2point distance
1723-
}elseif (v_point.z<v_high.z) {
1724-
retval=distance_vector_point_3d (&v_point,v_low.x,v_high.y,v_point.z);//point2line distance
1725-
}else {
1726-
retval=distance_vector_point_3d (&v_point,v_low.x,v_high.y,v_high.z);//point2point distance
1788+
}
1789+
elseif (v_point.y<v_high.y)
1790+
{
1791+
if (v_point.z<v_low.z)
1792+
{
1793+
/* point2plane distance */
1794+
retval=distance_vector_point_3d(&v_point,v_point.x,v_point.y,v_low.z);
1795+
}
1796+
elseif (v_point.z<v_high.z)
1797+
{
1798+
/* inside cube */
1799+
retval=0;
1800+
}
1801+
else
1802+
{
1803+
/* point2plane distance */
1804+
retval=distance_vector_point_3d(&v_point,v_point.x,v_point.y,v_high.z);
17271805
}
17281806
}
1729-
}elseif(v_point.x<v_high.x) {
1730-
if(v_point.y<v_low.y) {
1731-
if(v_point.z<v_low.z) {
1732-
retval=distance_vector_point_3d (&v_point,v_point.x,v_low.y,v_low.z);//p2line distance
1733-
}elseif (v_point.z<v_high.z) {
1734-
retval=distance_vector_point_3d (&v_point,v_point.x,v_low.y,v_point.z);//point2plane distance
1735-
}else {
1736-
retval=distance_vector_point_3d (&v_point,v_point.x,v_low.y,v_high.z);//point2line distance
1737-
}
1738-
}elseif(v_point.y<v_high.y) {
1739-
if(v_point.z<v_low.z) {
1740-
retval=distance_vector_point_3d (&v_point,v_point.x,v_point.y ,v_low.z);//point2plane distance
1741-
}elseif (v_point.z<v_high.z) {
1742-
retval=0;// inside cube
1743-
}else {
1744-
retval=distance_vector_point_3d (&v_point,v_point.x,v_point.y,v_high.z);//point2plane distance
1807+
else
1808+
{
1809+
if (v_point.z<v_low.z)
1810+
{
1811+
/* point2line distance */
1812+
retval=distance_vector_point_3d(&v_point,v_point.x,v_high.y,v_low.z);
1813+
}
1814+
elseif (v_point.z<v_high.z)
1815+
{
1816+
/* point2plane distance */
1817+
retval=distance_vector_point_3d(&v_point,v_point.x,v_high.y,v_point.z);
17451818
}
1746-
}else {
1747-
if(v_point.z<v_low.z) {
1748-
retval=distance_vector_point_3d (&v_point,v_point.x,v_high.y,v_low.z);//point2line distance
1749-
}elseif (v_point.z<v_high.z) {
1750-
retval=distance_vector_point_3d (&v_point,v_point.x,v_high.y,v_point.z);//point2plane distance
1751-
}else {
1752-
retval=distance_vector_point_3d (&v_point,v_point.x,v_high.y,v_high.z);//point2line distance
1819+
else
1820+
{
1821+
/* point2line distance */
1822+
retval=distance_vector_point_3d(&v_point,v_point.x,v_high.y,v_high.z);
17531823
}
17541824
}
1755-
}else {
1756-
if(v_point.y<v_low.y) {
1757-
if(v_point.z<v_low.z) {
1758-
retval=distance_vector_point_3d (&v_point,v_high.x,v_low.y,v_low.z);//p2p distance
1759-
}elseif (v_point.z<v_high.z) {
1760-
retval=distance_vector_point_3d (&v_point,v_high.x,v_low.y,v_point.z);//point2line distance
1761-
}else {
1762-
retval=distance_vector_point_3d (&v_point,v_high.x,v_low.y,v_high.z);//point2point distance
1763-
}
1764-
}elseif(v_point.y<v_high.y) {
1765-
if(v_point.z<v_low.z) {
1766-
retval=distance_vector_point_3d (&v_point,v_high.x,v_point.y ,v_low.z);//point2line distance
1767-
}elseif (v_point.z<v_high.z) {
1768-
retval=distance_vector_point_3d (&v_point,v_high.x,v_point.y ,v_point.z);//point2plane distance
1769-
}else {
1770-
retval=distance_vector_point_3d (&v_point,v_high.x,v_point.y,v_high.z);//point2line distance
1825+
}
1826+
else
1827+
{
1828+
if (v_point.y<v_low.y)
1829+
{
1830+
if (v_point.z<v_low.z)
1831+
{
1832+
/* p2p distance */
1833+
retval=distance_vector_point_3d(&v_point,v_high.x,v_low.y,v_low.z);
17711834
}
1772-
}else {
1773-
if(v_point.z<v_low.z) {
1774-
retval=distance_vector_point_3d (&v_point,v_high.x,v_high.y,v_low.z);//point2point distance
1775-
}elseif (v_point.z<v_high.z) {
1776-
retval=distance_vector_point_3d (&v_point,v_high.x,v_high.y,v_point.z);//point2line distance
1777-
}else {
1778-
retval=distance_vector_point_3d (&v_point,v_high.x,v_high.y,v_high.z);//point2point distance
1835+
elseif (v_point.z<v_high.z)
1836+
{
1837+
/* point2line distance */
1838+
retval=distance_vector_point_3d(&v_point,v_high.x,v_low.y,v_point.z);
1839+
}
1840+
else
1841+
{
1842+
/* point2point distance */
1843+
retval=distance_vector_point_3d(&v_point,v_high.x,v_low.y,v_high.z);
1844+
}
1845+
}
1846+
elseif (v_point.y<v_high.y)
1847+
{
1848+
if (v_point.z<v_low.z)
1849+
{
1850+
/* point2line distance */
1851+
retval=distance_vector_point_3d(&v_point,v_high.x,v_point.y,v_low.z);
1852+
}
1853+
elseif (v_point.z<v_high.z)
1854+
{
1855+
/* point2plane distance */
1856+
retval=distance_vector_point_3d(&v_point,v_high.x,v_point.y,v_point.z);
1857+
}
1858+
else
1859+
{
1860+
/* point2line distance */
1861+
retval=distance_vector_point_3d(&v_point,v_high.x,v_point.y,v_high.z);
1862+
}
1863+
}
1864+
else
1865+
{
1866+
if (v_point.z<v_low.z)
1867+
{
1868+
/* point2point distance */
1869+
retval=distance_vector_point_3d(&v_point,v_high.x,v_high.y,v_low.z);
1870+
}
1871+
elseif (v_point.z<v_high.z)
1872+
{
1873+
/* point2line distance */
1874+
retval=distance_vector_point_3d(&v_point,v_high.x,v_high.y,v_point.z);
1875+
}
1876+
else
1877+
{
1878+
/* point2point distance */
1879+
retval=distance_vector_point_3d(&v_point,v_high.x,v_high.y,v_high.z);
17791880
}
17801881
}
17811882
}
1782-
1883+
17831884
elog(DEBUG1,"distance (%lg,%lg,%lg %lg,%lg,%lg) <-> (%lg,%lg) = %lg",
1784-
v_low.x,v_low.y,v_low.z,
1785-
v_high.x,v_high.y,v_high.z,
1786-
point->lng,point->lat,
1787-
retval
1788-
);
1885+
v_low.x,v_low.y,v_low.z,
1886+
v_high.x,v_high.y,v_high.z,
1887+
point->lng,point->lat,
1888+
retval
1889+
);
17891890
break;
17901891

17911892
default:
17921893
elog(ERROR,"unrecognized cube strategy number: %d",strategy);
1793-
retval=0;/* keep compiler quiet */
1894+
retval=0;/* keep compiler quiet */
17941895
break;
17951896
}
1897+
17961898
PG_RETURN_FLOAT8(retval);
17971899
}
17981900

1799-
1800-
18011901
/*
18021902
* Represents information about an entry that can be placed to either group
18031903
* without affecting overlap over selected axis ("common entry").
@@ -2329,7 +2429,7 @@ do_picksplit(Box3D *boxes, OffsetNumber maxoff, GIST_SPLITVEC *v)
23292429
{
23302430
box=&boxes[i];
23312431
commonEntries[i].delta=fabs((unionSizeBox3D(leftBox,box)-leftBoxSize)-
2332-
(unionSizeBox3D(rightBox,box)-rightBoxSize));
2432+
(unionSizeBox3D(rightBox,box)-rightBoxSize));
23332433
}
23342434

23352435
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp