PostGIS 3.7.0dev-r@@SVN_REVISION@@
Loading...
Searching...
No Matches

◆ test_raster_geos_contains_properly()

static void test_raster_geos_contains_properly ( )
static

Definition at line 1556 of file cu_spatial_relationship.c.

1556 {
1557 rt_raster rast1;
1558 rt_raster rast2;
1559 rt_band band1;
1560 rt_band band2;
1561 double nodata;
1562 int rtn;
1563 int result;
1564
1565 /*
1566 rast1
1567
1568 (-1, -1)
1569 +-+-+
1570 |1|1|
1571 +-+-+
1572 |1|1|
1573 +-+-+
1574 (1, 1)
1575 */
1576 rast1 = rt_raster_new(2, 2);
1577 CU_ASSERT(rast1 != NULL);
1578 rt_raster_set_scale(rast1, 1, 1);
1579 rt_raster_set_offsets(rast1, -1, -1);
1580
1581 band1 = cu_add_band(rast1, PT_8BUI, 1, 0);
1582 CU_ASSERT(band1 != NULL);
1583 rt_band_set_nodata(band1, 0, NULL);
1584 rtn = rt_band_set_pixel(band1, 0, 0, 1, NULL);
1585 rtn = rt_band_set_pixel(band1, 0, 1, 1, NULL);
1586 rtn = rt_band_set_pixel(band1, 1, 0, 1, NULL);
1587 rtn = rt_band_set_pixel(band1, 1, 1, 1, NULL);
1588
1589 rt_band_get_nodata(band1, &nodata);
1590 CU_ASSERT_EQUAL(nodata, 0);
1591
1593 rast1, 0,
1594 rast1, 0,
1595 &result
1596 );
1597 CU_ASSERT_EQUAL(rtn, ES_NONE);
1598 CU_ASSERT_NOT_EQUAL(result, 1);
1599
1600 /*
1601 rast2
1602
1603 (0, 0)
1604 +-+-+
1605 |1|1|
1606 +-+-+
1607 |1|1|
1608 +-+-+
1609 (2, 2)
1610 */
1611 rast2 = rt_raster_new(2, 2);
1612 CU_ASSERT(rast2 != NULL);
1613 rt_raster_set_scale(rast2, 1, 1);
1614
1615 band2 = cu_add_band(rast2, PT_8BUI, 1, 0);
1616 CU_ASSERT(band2 != NULL);
1617 rt_band_set_nodata(band2, 0, NULL);
1618 rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
1619 rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
1620 rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
1621 rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
1622
1623 rt_band_get_nodata(band2, &nodata);
1624 CU_ASSERT_EQUAL(nodata, 0);
1625
1627 rast1, 0,
1628 rast2, 0,
1629 &result
1630 );
1631 CU_ASSERT_EQUAL(rtn, ES_NONE);
1632 CU_ASSERT_NOT_EQUAL(result, 1);
1633
1635 rast1, -1,
1636 rast2, -1,
1637 &result
1638 );
1639 CU_ASSERT_EQUAL(rtn, ES_NONE);
1640 CU_ASSERT_NOT_EQUAL(result, 1);
1641
1642 /*
1643 rast2
1644
1645 (0, 0)
1646 +-+-+
1647 |0|1|
1648 +-+-+
1649 |1|1|
1650 +-+-+
1651 (2, 2)
1652 */
1653 rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
1654
1656 rast1, 0,
1657 rast2, 0,
1658 &result
1659 );
1660 CU_ASSERT_EQUAL(rtn, ES_NONE);
1661 CU_ASSERT_NOT_EQUAL(result, 1);
1662
1663 /*
1664 rast2
1665
1666 (0, 0)
1667 +-+-+
1668 |1|0|
1669 +-+-+
1670 |1|1|
1671 +-+-+
1672 (2, 2)
1673 */
1674 rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
1675 rtn = rt_band_set_pixel(band2, 1, 0, 0, NULL);
1676
1678 rast1, 0,
1679 rast2, 0,
1680 &result
1681 );
1682 CU_ASSERT_EQUAL(rtn, ES_NONE);
1683 CU_ASSERT_NOT_EQUAL(result, 1);
1684
1685 /*
1686 rast2
1687
1688 (0, 0)
1689 +-+-+
1690 |0|0|
1691 +-+-+
1692 |0|1|
1693 +-+-+
1694 (2, 2)
1695 */
1696 rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
1697 rtn = rt_band_set_pixel(band2, 1, 0, 0, NULL);
1698 rtn = rt_band_set_pixel(band2, 0, 1, 0, NULL);
1699
1701 rast1, 0,
1702 rast2, 0,
1703 &result
1704 );
1705 CU_ASSERT_EQUAL(rtn, ES_NONE);
1706 CU_ASSERT_NOT_EQUAL(result, 1);
1707
1708 /*
1709 rast2
1710
1711 (0, 0)
1712 +-+-+
1713 |0|0|
1714 +-+-+
1715 |0|0|
1716 +-+-+
1717 (2, 2)
1718 */
1719 rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
1720 rtn = rt_band_set_pixel(band2, 1, 0, 0, NULL);
1721 rtn = rt_band_set_pixel(band2, 0, 1, 0, NULL);
1722 rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
1723
1725 rast1, 0,
1726 rast2, 0,
1727 &result
1728 );
1729 CU_ASSERT_EQUAL(rtn, ES_NONE);
1730 CU_ASSERT_NOT_EQUAL(result, 1);
1731
1732 /*
1733 rast2
1734
1735 (2, 0)
1736 +-+-+
1737 |1|1|
1738 +-+-+
1739 |1|1|
1740 +-+-+
1741 (4, 2)
1742 */
1743 rt_raster_set_offsets(rast2, 2, 0);
1744
1745 rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
1746 rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
1747 rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
1748 rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
1749
1751 rast1, 0,
1752 rast2, 0,
1753 &result
1754 );
1755 CU_ASSERT_EQUAL(rtn, ES_NONE);
1756 CU_ASSERT_NOT_EQUAL(result, 1);
1757
1758 /*
1759 rast2
1760
1761 (0, 1)
1762 +-+-+
1763 |1|1|
1764 +-+-+
1765 |1|1|
1766 +-+-+
1767 (2, 3)
1768 */
1769 rt_raster_set_offsets(rast2, 0, 1);
1770
1771 rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
1772 rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
1773 rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
1774 rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
1775
1777 rast1, 0,
1778 rast2, 0,
1779 &result
1780 );
1781 CU_ASSERT_EQUAL(rtn, ES_NONE);
1782 CU_ASSERT_NOT_EQUAL(result, 1);
1783
1784 /*
1785 rast2
1786
1787 (-1, 1)
1788 +-+-+
1789 |1|1|
1790 +-+-+
1791 |1|1|
1792 +-+-+
1793 (1, 3)
1794 */
1795 rt_raster_set_offsets(rast2, -1, 1);
1796
1797 rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
1798 rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
1799 rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
1800 rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
1801
1803 rast1, 0,
1804 rast2, 0,
1805 &result
1806 );
1807 CU_ASSERT_EQUAL(rtn, ES_NONE);
1808 CU_ASSERT_NOT_EQUAL(result, 1);
1809
1810 /*
1811 rast2
1812
1813 (0.1, 0.1)
1814 +-+-+
1815 |1|1|
1816 +-+-+
1817 |1|1|
1818 +-+-+
1819 (0.9, 0.9)
1820 */
1821 rt_raster_set_offsets(rast2, 0.1, 0.1);
1822 rt_raster_set_scale(rast2, 0.4, 0.4);
1823
1824 rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
1825 rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
1826 rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
1827 rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
1828
1830 rast1, 0,
1831 rast2, 0,
1832 &result
1833 );
1834 CU_ASSERT_EQUAL(rtn, ES_NONE);
1835 CU_ASSERT_EQUAL(result, 1);
1836
1837 /*
1838 rast2
1839
1840 (-0.1, 0.1)
1841 +-+-+
1842 |1|1|
1843 +-+-+
1844 |1|1|
1845 +-+-+
1846 (0.9, 0.9)
1847 */
1848 rt_raster_set_offsets(rast2, -0.1, 0.1);
1849
1851 rast1, 0,
1852 rast2, 0,
1853 &result
1854 );
1855 CU_ASSERT_EQUAL(rtn, ES_NONE);
1856 CU_ASSERT_EQUAL(result, 1);
1857
1858 cu_free_raster(rast2);
1859
1860 /*
1861 rast2
1862
1863 (0, 0)
1864 +-+-+-+
1865 |1|1|1|
1866 +-+-+-+
1867 |1|1|1|
1868 +-+-+-+
1869 |1|1|1|
1870 +-+-+-+
1871 (3, 3)
1872 */
1873 rast2 = rt_raster_new(3, 3);
1874 CU_ASSERT(rast2 != NULL);
1875 rt_raster_set_scale(rast2, 1, 1);
1876
1877 band2 = cu_add_band(rast2, PT_8BUI, 1, 0);
1878 CU_ASSERT(band2 != NULL);
1879 rt_band_set_nodata(band2, 0, NULL);
1880 rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
1881 rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
1882 rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
1883 rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
1884 rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
1885 rtn = rt_band_set_pixel(band2, 1, 2, 1, NULL);
1886 rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
1887 rtn = rt_band_set_pixel(band2, 2, 1, 1, NULL);
1888 rtn = rt_band_set_pixel(band2, 2, 2, 1, NULL);
1889
1890 rt_band_get_nodata(band2, &nodata);
1891 CU_ASSERT_EQUAL(nodata, 0);
1892
1894 rast1, 0,
1895 rast2, 0,
1896 &result
1897 );
1898 CU_ASSERT_EQUAL(rtn, ES_NONE);
1899 CU_ASSERT_NOT_EQUAL(result, 1);
1900
1901 /*
1902 rast2
1903
1904 (-2, -2)
1905 +-+-+-+
1906 |1|1|1|
1907 +-+-+-+
1908 |1|1|1|
1909 +-+-+-+
1910 |1|1|1|
1911 +-+-+-+
1912 (1, 1)
1913 */
1914 rt_raster_set_offsets(rast2, -2, -2);
1915
1916 rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
1917 rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
1918 rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
1919 rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
1920 rtn = rt_band_set_pixel(band2, 1, 1, 1, NULL);
1921 rtn = rt_band_set_pixel(band2, 1, 2, 1, NULL);
1922 rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
1923 rtn = rt_band_set_pixel(band2, 2, 1, 1, NULL);
1924 rtn = rt_band_set_pixel(band2, 2, 2, 1, NULL);
1925
1927 rast1, 0,
1928 rast2, 0,
1929 &result
1930 );
1931 CU_ASSERT_EQUAL(rtn, ES_NONE);
1932 CU_ASSERT_NOT_EQUAL(result, 1);
1933
1934 /*
1935 rast2
1936
1937 (-2, -2)
1938 +-+-+-+
1939 |0|1|1|
1940 +-+-+-+
1941 |1|0|1|
1942 +-+-+-+
1943 |1|1|0|
1944 +-+-+-+
1945 (1, 1)
1946 */
1947 rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
1948 rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
1949 rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
1950 rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
1951 rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
1952 rtn = rt_band_set_pixel(band2, 1, 2, 1, NULL);
1953 rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
1954 rtn = rt_band_set_pixel(band2, 2, 1, 1, NULL);
1955 rtn = rt_band_set_pixel(band2, 2, 2, 0, NULL);
1956
1958 rast1, 0,
1959 rast2, 0,
1960 &result
1961 );
1962 CU_ASSERT_EQUAL(rtn, ES_NONE);
1963 CU_ASSERT_NOT_EQUAL(result, 1);
1964
1965 /*
1966 rast2
1967
1968 (-2, -2)
1969 +-+-+-+
1970 |0|1|1|
1971 +-+-+-+
1972 |1|0|0|
1973 +-+-+-+
1974 |1|0|0|
1975 +-+-+-+
1976 (1, 1)
1977 */
1978 rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
1979 rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
1980 rtn = rt_band_set_pixel(band2, 0, 2, 1, NULL);
1981 rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
1982 rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
1983 rtn = rt_band_set_pixel(band2, 1, 2, 0, NULL);
1984 rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
1985 rtn = rt_band_set_pixel(band2, 2, 1, 0, NULL);
1986 rtn = rt_band_set_pixel(band2, 2, 2, 0, NULL);
1987
1989 rast1, 0,
1990 rast2, 0,
1991 &result
1992 );
1993 CU_ASSERT_EQUAL(rtn, ES_NONE);
1994 CU_ASSERT_NOT_EQUAL(result, 1);
1995
1996 /*
1997 rast2
1998
1999 (-2, -2)
2000 +-+-+-+
2001 |0|1|0|
2002 +-+-+-+
2003 |1|0|0|
2004 +-+-+-+
2005 |0|0|0|
2006 +-+-+-+
2007 (1, 1)
2008 */
2009 rtn = rt_band_set_pixel(band2, 0, 0, 0, NULL);
2010 rtn = rt_band_set_pixel(band2, 0, 1, 1, NULL);
2011 rtn = rt_band_set_pixel(band2, 0, 2, 0, NULL);
2012 rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
2013 rtn = rt_band_set_pixel(band2, 1, 1, 0, NULL);
2014 rtn = rt_band_set_pixel(band2, 1, 2, 0, NULL);
2015 rtn = rt_band_set_pixel(band2, 2, 0, 0, NULL);
2016 rtn = rt_band_set_pixel(band2, 2, 1, 0, NULL);
2017 rtn = rt_band_set_pixel(band2, 2, 2, 0, NULL);
2018
2020 rast1, 0,
2021 rast2, 0,
2022 &result
2023 );
2024 CU_ASSERT_EQUAL(rtn, ES_NONE);
2025 CU_ASSERT_NOT_EQUAL(result, 1);
2026
2027 cu_free_raster(rast2);
2028
2029 /* skew tests */
2030 /* rast2 (skewed by -0.5, 0.5) */
2031 rast2 = rt_raster_new(3, 3);
2032 CU_ASSERT(rast2 != NULL);
2033 rt_raster_set_scale(rast2, 1, 1);
2034 rt_raster_set_skews(rast2, -0.5, 0.5);
2035
2036 band2 = cu_add_band(rast2, PT_8BUI, 1, 0);
2037 CU_ASSERT(band2 != NULL);
2038 rt_band_set_nodata(band2, 0, NULL);
2039 rtn = rt_band_set_pixel(band2, 0, 0, 1, NULL);
2040 rtn = rt_band_set_pixel(band2, 0, 1, 2, NULL);
2041 rtn = rt_band_set_pixel(band2, 0, 2, 3, NULL);
2042 rtn = rt_band_set_pixel(band2, 1, 0, 1, NULL);
2043 rtn = rt_band_set_pixel(band2, 1, 1, 2, NULL);
2044 rtn = rt_band_set_pixel(band2, 1, 2, 3, NULL);
2045 rtn = rt_band_set_pixel(band2, 2, 0, 1, NULL);
2046 rtn = rt_band_set_pixel(band2, 2, 1, 2, NULL);
2047 rtn = rt_band_set_pixel(band2, 2, 2, 3, NULL);
2048
2050 rast1, 0,
2051 rast2, 0,
2052 &result
2053 );
2054 CU_ASSERT_EQUAL(rtn, ES_NONE);
2055 CU_ASSERT_NOT_EQUAL(result, 1);
2056
2057 /* rast2 (skewed by -1, 1) */
2058 rt_raster_set_skews(rast2, -1, 1);
2059
2061 rast1, 0,
2062 rast2, 0,
2063 &result
2064 );
2065 CU_ASSERT_EQUAL(rtn, ES_NONE);
2066 CU_ASSERT_NOT_EQUAL(result, 1);
2067
2068 /* rast2 (skewed by 1, -1) */
2069 rt_raster_set_skews(rast2, 1, -1);
2070
2072 rast1, 0,
2073 rast2, 0,
2074 &result
2075 );
2076 CU_ASSERT_EQUAL(rtn, ES_NONE);
2077 CU_ASSERT_NOT_EQUAL(result, 1);
2078
2079 cu_free_raster(rast2);
2080 cu_free_raster(rast1);
2081}
char result[OUT_DOUBLE_BUFFER_SIZE]
Definition cu_print.c:267
rt_errorstate rt_raster_contains_properly(rt_raster rast1, int nband1, rt_raster rast2, int nband2, int *contains)
Return ES_ERROR if error occurred in function.
void rt_raster_set_scale(rt_raster raster, double scaleX, double scaleY)
Set scale in projection units.
Definition rt_raster.c:141
@ PT_8BUI
Definition librtcore.h:193
void rt_raster_set_skews(rt_raster raster, double skewX, double skewY)
Set skews about the X and Y axis.
Definition rt_raster.c:172
rt_raster rt_raster_new(uint32_t width, uint32_t height)
Construct a raster with given dimensions.
Definition rt_raster.c:52
rt_errorstate rt_band_set_nodata(rt_band band, double val, int *converted)
Set nodata value.
Definition rt_band.c:892
rt_errorstate rt_band_set_pixel(rt_band band, int x, int y, double val, int *converted)
Set single pixel's value.
Definition rt_band.c:1140
@ ES_NONE
Definition librtcore.h:182
rt_errorstate rt_band_get_nodata(rt_band band, double *nodata)
Get NODATA value.
Definition rt_band.c:2067
void rt_raster_set_offsets(rt_raster raster, double x, double y)
Set insertion points in projection units.
Definition rt_raster.c:203
rt_band cu_add_band(rt_raster raster, rt_pixtype pixtype, int hasnodata, double nodataval)
void cu_free_raster(rt_raster raster)

References cu_add_band(), cu_free_raster(), ES_NONE, PT_8BUI, result, rt_band_get_nodata(), rt_band_set_nodata(), rt_band_set_pixel(), rt_raster_contains_properly(), rt_raster_new(), rt_raster_set_offsets(), rt_raster_set_scale(), and rt_raster_set_skews().

Referenced by spatial_relationship_suite_setup().

Here is the call graph for this function:
Here is the caller graph for this function: