gdouble londist = e - w;
gdouble latdist = n - s;
- gdouble xy[][3] = {
+ gdouble xy[3][2] = {
{(lon[0]-w)/londist, 1-(lat[0]-s)/latdist},
{(lon[1]-w)/londist, 1-(lat[1]-s)/latdist},
{(lon[2]-w)/londist, 1-(lat[2]-s)/latdist},
};
+ //if ((lat[0] == 90 && (xy[0][0] < 0 || xy[0][0] > 1)) ||
+ // (lat[1] == 90 && (xy[1][0] < 0 || xy[1][0] > 1)) ||
+ // (lat[2] == 90 && (xy[2][0] < 0 || xy[2][0] > 1)))
+ // g_message("w,e=%4.f,%4.f "
+ // "lat,lon,x,y="
+ // "%4.1f,%4.0f,%4.2f,%4.2f "
+ // "%4.1f,%4.0f,%4.2f,%4.2f "
+ // "%4.1f,%4.0f,%4.2f,%4.2f ",
+ // w,e,
+ // lat[0], lon[0], xy[0][0], xy[0][1],
+ // lat[1], lon[1], xy[1][0], xy[1][1],
+ // lat[2], lon[2], xy[2][0], xy[2][1]);
+
+ /* Fix poles */
+ if (lat[0] == 90 || lat[0] == -90) xy[0][0] = 0.5;
+ if (lat[1] == 90 || lat[1] == -90) xy[1][0] = 0.5;
+ if (lat[2] == 90 || lat[2] == -90) xy[2][0] = 0.5;
+
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, *(guint*)tile->data);
glBegin(GL_TRIANGLES);
gint row = lat_offset / lat_step;
gint col = lon_offset / lon_step;
+ if (lon == 180) col--;
+ if (lat == -90) row--;
+
+ //if (lon == 180 || lon == -180)
+ // g_message("lat=%f,lon=%f step=%f,%f off=%f,%f row=%d/%d,col=%d/%d",
+ // lat,lon, lat_step,lon_step, lat_offset,lon_offset, row,rows,col,cols);
+
if (row < 0 || row >= rows || col < 0 || col >= cols)
return NULL;
else if (self->children[row][col] && self->children[row][col]->data)
guint x_flr = (int)x;
guint y_flr = (int)y;
+ //if (lon == 180 || lon == -180)
+ // g_message("lon=%f w=%d min=%f max=%f dist=%f x=%f rem=%f flr=%d",
+ // lon, w, xmin, xmax, xdist, x, x_rem, x_flr);
+
/* TODO: Fix interpolation at edges:
* - Pad these at the edges instead of wrapping/truncating
* - Figure out which pixels to index (is 0,0 edge, center, etc) */