652 enum line_points {X1, Y1, X2, Y2};
654 double line1[4] = {0.};
655 double line2[4] = {0.};
659 double gt1[6] = {0.};
660 double gt2[6] = {0.};
661 double igt1[6] = {0};
662 double igt2[6] = {0};
693 &(line1[X1]), &(line1[Y1]),
700 &(line1[X2]), &(line1[Y2]),
707 &(line2[X1]), &(line2[Y1]),
714 &(line2[X2]), &(line2[Y2]),
719 if (
FLT_EQ(((line1[X2] - line1[X1]) * (line2[Y2] - line2[Y1])),
720 ((line2[X2] - line2[X1]) * (line1[Y2] - line1[Y1]))))
727 RASTER_DEBUGF(4,
"byHeight: %d, dimValue: %d", byHeight, dimValue);
730 for (coloffset = 0; coloffset < 3; coloffset++) {
731 for (rowoffset = 0; rowoffset < 3; rowoffset++) {
733 for (col = coloffset; col <= width1; col += 3) {
738 &(line1[X1]), &(line1[Y1]),
745 &(line1[X2]), &(line1[Y2]),
750 for (row = rowoffset; row <= dimValue; row += 3) {
756 &(line2[X1]), &(line2[Y1]),
763 &(line2[X2]), &(line2[Y2]),
771 &(line2[X1]), &(line2[Y1]),
778 &(line2[X2]), &(line2[Y2]),
785 line1[X1], line1[Y1], line1[X2], line1[Y2]);
787 line2[X1], line2[Y1], line2[X2], line2[Y2]);
791 d = ((line1[X1] - line1[X2]) * (line2[Y1] - line2[Y2])) - ((line1[Y1] - line1[Y2]) * (line2[X1] - line2[X2]));
797 P[pX] = (((line1[X1] * line1[Y2]) - (line1[Y1] * line1[X2])) * (line2[X1] - line2[X2])) -
798 ((line1[X1] - line1[X2]) * ((line2[X1] * line2[Y2]) - (line2[Y1] * line2[X2])));
801 P[pY] = (((line1[X1] * line1[Y2]) - (line1[Y1] * line1[X2])) * (line2[Y1] - line2[Y2])) -
802 ((line1[Y1] - line1[Y2]) * ((line2[X1] * line2[Y2]) - (line2[Y1] * line2[X2])));
809 (
FLT_EQ(P[pX], line1[X1]) ||
FLT_EQ(P[pX], line1[X2])) ||
810 (P[pX] > fmin(line1[X1], line1[X2]) && (P[pX] < fmax(line1[X1], line1[X2])))
812 (
FLT_EQ(P[pY], line1[Y1]) ||
FLT_EQ(P[pY], line1[Y2])) ||
813 (P[pY] > fmin(line1[Y1], line1[Y2]) && (P[pY] < fmax(line1[Y1], line1[Y2])))
815 (
FLT_EQ(P[pX], line2[X1]) ||
FLT_EQ(P[pX], line2[X2])) ||
816 (P[pX] > fmin(line2[X1], line2[X2]) && (P[pX] < fmax(line2[X1], line2[X2])))
818 (
FLT_EQ(P[pY], line2[Y1]) ||
FLT_EQ(P[pY], line2[Y2])) ||
819 (P[pY] > fmin(line2[Y1], line2[Y2]) && (P[pY] < fmax(line2[Y1], line2[Y2])))
823 for (i = 0; i < 8; i++) adjacent[i] = 0;
826 for (i = 0; i < 8; i++) {
829 Qw[pX] = P[pX] - xscale;
830 Qw[pY] = P[pY] + yscale;
834 Qw[pX] = P[pX] - xscale;
838 Qw[pX] = P[pX] - xscale;
839 Qw[pY] = P[pY] - yscale;
844 Qw[pY] = P[pY] - yscale;
847 Qw[pX] = P[pX] + xscale;
848 Qw[pY] = P[pY] - yscale;
852 Qw[pX] = P[pX] + xscale;
857 Qw[pX] = P[pX] + xscale;
858 Qw[pY] = P[pY] + yscale;
863 Qw[pY] = P[pY] + yscale;
872 &(Qr[pX]), &(Qr[pY]),
879 (Qr[pX] < 0 || Qr[pX] > width1 ||
FLT_EQ(Qr[pX], width1)) ||
880 (Qr[pY] < 0 || Qr[pY] > height1 ||
FLT_EQ(Qr[pY], height1))
884 else if (hasnodata1 ==
FALSE)
895 &(Qr[pX]), &(Qr[pY]),
902 (Qr[pX] < 0 || Qr[pX] > width2 ||
FLT_EQ(Qr[pX], width2)) ||
903 (Qr[pY] < 0 || Qr[pY] > height2 ||
FLT_EQ(Qr[pY], height2))
907 else if (hasnodata2 ==
FALSE)
922 (hasnodata1 ==
FALSE) || !isnodata1
927 (hasnodata2 ==
FALSE) || !isnodata2
933 if (noval1 || noval2) {
934 RASTER_DEBUGF(4,
"noval1 = %d, noval2 = %d", noval1, noval2);
940 ((hasnodata1 ==
FALSE) || !isnodata1) &&
941 ((hasnodata2 ==
FALSE) || !isnodata2)
950 for (i = 0; i < 4; i++) {
952 , i, adjacent[i], i + 4, adjacent[i + 4]);
953 if (adjacent[i] == 0)
continue;
955 if (adjacent[i] + adjacent[i + 4] == 4) {
#define RASTER_DEBUG(level, msg)
rt_errorstate rt_raster_cell_to_geopoint(rt_raster raster, double xr, double yr, double *xw, double *yw, double *gt)
Convert an xr, yr raster point to an xw, yw point on map.
#define RASTER_DEBUGF(level, msg,...)
rt_errorstate rt_raster_geopoint_to_cell(rt_raster raster, double xw, double yw, double *xr, double *yr, double *igt)
Convert an xw, yw map point to a xr, yr raster point.
rt_errorstate rt_band_get_pixel(rt_band band, int x, int y, double *value, int *nodata)
Get pixel value.
double rt_raster_get_x_scale(rt_raster raster)
Get scale X in projection units.
uint16_t rt_raster_get_height(rt_raster raster)
uint16_t rt_raster_get_width(rt_raster raster)
double rt_raster_get_y_scale(rt_raster raster)
Get scale Y in projection units.