1
0
Fork 0

Compile warnings cleanup round 1

This commit is contained in:
PSadrozinski 2011-12-25 20:54:37 -05:00 committed by Christian Schmitt
parent 48774e19e8
commit 27c31404ca
12 changed files with 1369 additions and 1407 deletions

View file

@ -605,7 +605,7 @@ void build_airport( string airport_id, float alt_m,
}
#else
/* Ralf Gerlich: Generate Taxiways in specified order from bottom to top */
for ( i=0; i<taxiways.size(); ++i ) {
for ( i=0; i<(int)taxiways.size(); ++i ) {
SG_LOG( SG_GENERAL, SG_DEBUG, "generating " << i );
build_runway( taxiways[i], alt_m,
&rwy_polys, &texparams, &accum,
@ -970,7 +970,7 @@ void build_airport( string airport_id, float alt_m,
tri_materials.push_back( "Grass" );
std::vector < SGGeod > geodNodes;
for ( j = 0; j < nodes.get_node_list().size(); j++ ) {
for ( j = 0; j < (int)nodes.get_node_list().size(); j++ ) {
Point3D node = nodes.get_node_list()[j];
geodNodes.push_back( SGGeod::fromDegM( node.x(), node.y(), node.z() ) );
}
@ -1162,7 +1162,7 @@ void build_airport( string airport_id, float alt_m,
strip_materials.push_back( "Grass" );
std::vector < SGGeod > geodNodes;
for ( j = 0; j < nodes.get_node_list().size(); j++ ) {
for ( j = 0; j < (int)nodes.get_node_list().size(); j++ ) {
Point3D node = nodes.get_node_list()[j];
geodNodes.push_back( SGGeod::fromDegM( node.x(), node.y(), node.z() ) );
}
@ -1285,7 +1285,7 @@ void build_airport( string airport_id, float alt_m,
wgs84_nodes.push_back( cart );
}
SGSphered d;
for ( i = 0; i < wgs84_nodes.size(); ++i ) {
for ( i = 0; i < (int)wgs84_nodes.size(); ++i ) {
d.expandBy(wgs84_nodes[ i ]);
}
@ -1306,13 +1306,13 @@ void build_airport( string airport_id, float alt_m,
string name = airport_id + ".btg";
std::vector< SGVec3f > normals_3f;
for ( i=0; i < normals.get_node_list().size(); i++ ) {
for ( i=0; i < (int)normals.get_node_list().size(); i++ ) {
Point3D node = normals.get_node_list()[i];
normals_3f.push_back( node.toSGVec3f() );
}
std::vector< SGVec2f > texcoords_2f;
for ( i=0; i < texcoords.get_node_list().size(); i++ ) {
for ( i=0; i < (int)texcoords.get_node_list().size(); i++ ) {
Point3D node = texcoords.get_node_list()[i];
texcoords_2f.push_back( node.toSGVec2f() );
}

View file

@ -69,7 +69,7 @@ getIntersection (const Point3D &p0, const Point3D &p1,
void
makePolygon (const Point3D &p, double width, TGPolygon &polygon)
{
double x, y, az;
double x = 0.0f, y = 0.0f, az = 0.0f;
double lon = p.x();
double lat = p.y();
@ -101,7 +101,12 @@ makePolygon (const Line &line, double width, TGPolygon &polygon)
const Point3D p1 = line.getPoint(i);
const Point3D p2 = line.getPoint(i+1);
double angle1, angle2, dist, x, y, az;
double angle1 = 0.0f;
double angle2 = 0.0f;
double dist = 0.0f;
double x = 0.0f;
double y = 0.0f;
double az = 0.0f;
geo_inverse_wgs_84(0, p1.y(), p1.x(), p2.y(), p2.x(), &angle1, &angle2, &dist);
polygon.erase();
@ -420,9 +425,12 @@ makePolygonsTP (const Line &line, double width, poly_list& polys, texparams_list
Point3D prev_inner = Point3D(0.0f, 0.0f, 0.0f);
Point3D prev_outer = Point3D(0.0f, 0.0f, 0.0f);
double last_end_v;
double heading, az2, dist;
double pt_x, pt_y;
double last_end_v = 0.0f;
double heading = 0.0f;
double az2 = 0.0f;
double dist = 0.0f;
double pt_x = 0.0f;
double pt_y = 0.0f;
TGPolygon poly;
TGTexParams tp;

View file

@ -415,6 +415,8 @@ double Area(const Polygon &poly)
case rtHi:
UseFullInt64Range = true;
break;
case rtLo:
break;
case rtError:
throw "Coordinate exceeds range bounds.";
}

View file

@ -37,7 +37,7 @@ strAppend (string &s, int i)
s += buf;
}
#if 0 /* UNUSED */
/**
* Append a double-precision real to a string.
*/
@ -48,7 +48,7 @@ strAppend (string &s, double f)
sprintf(buf, "%f", f);
s += buf;
}
#endif
/**
* Skip newlines.
@ -141,7 +141,6 @@ checkZeros (istream &input)
}
}
/**
* Check that the expected integer appears, or throw an exception.
*/
@ -157,7 +156,7 @@ expect (istream &input, int i)
}
}
#if 0 /* UNUSED */
/**
* Check that the expected real number appears, or throw an exception.
*/
@ -172,7 +171,7 @@ expect (istream &input, double f)
throw E00Exception(message.c_str());
}
}
#endif
/**
* Check that the expected string appears, or throw an exception.
@ -541,8 +540,6 @@ E00::readIFO ()
{
int line_pos = 0;
string line = "";
int intval;
double realval;
checkPrecision(*_input);
@ -689,7 +686,7 @@ E00::postProcess ()
const E00::IFO *
E00::getIFO (const string &fileName) const
{
for (int i = 0; i < ifo_section.size(); i++) {
for (int i = 0; i < (int)ifo_section.size(); i++) {
if (ifo_section[i].fileName == fileName)
return &(ifo_section[i]);
}
@ -705,7 +702,7 @@ E00::getIFOItem (const string &fileName, int entry,
return 0;
int pos = -1;
for (int i = 0; i < ifo->defs.size(); i++) {
for (int i = 0; i < (int)ifo->defs.size(); i++) {
if (ifo->defs[i].itemName == itemName)
pos = i;
}
@ -723,8 +720,8 @@ E00::getIFOItemType (const string &fileName, const string &itemName) const
if (ifo == 0)
return 0;
int pos = -1;
for (int i = 0; i < ifo->defs.size(); i++) {
// int pos = -1;
for (int i = 0; i < (int)ifo->defs.size(); i++) {
if (ifo->defs[i].itemName == itemName)
return &(ifo->defs[i].itemType);
}

File diff suppressed because it is too large Load diff

View file

@ -289,7 +289,7 @@ static int traverse_polygon(mcur, trnum, from, dir)
trap_t *t = &tr[trnum];
int mnew;
int v0, v1;
int retval;
int retval = 0;
int do_switch = FALSE;
if ((trnum <= 0) || visited[trnum])

View file

@ -57,9 +57,11 @@
static char rcsid[] =
"$Id: dbfadd.c,v 1.7 2002/01/15 14:36:07 warmerda Exp $";
#include "shapefil.h"
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include "shapefil.h"
int main( int argc, char ** argv )

View file

@ -76,8 +76,10 @@
* Initial revision
*/
#if 0
static char rcsid[] =
"$Id: shputils.c,v 1.7 2003/02/25 17:20:22 warmerda Exp $";
#endif
#include <stdlib.h>
#include "shapefil.h"
@ -121,6 +123,8 @@ void setext(char *pt, char *ext);
int strncasecmp2(char *s1, char *s2, int n);
void mergefields(void);
void findselect(void);
int findunit(char *unit);
void showitems(void);
int selectrec();
int check_theme_bnd();
@ -394,6 +398,9 @@ int main( int argc, char ** argv )
DBFWriteDoubleAttribute(hDBFappend, jRecord, pt[i],
(DBFReadDoubleAttribute( hDBF, iRecord, i )) );
break;
default:
break;
}
}
}
@ -686,8 +693,8 @@ char *pt;
isum = isum + itmp;
}
mean=isum/maxrec;
if (ilow < ihigh) printf("%d to %d \t(%.1f)",ilow,ihigh,mean);
else if (ilow == ihigh) printf("= %d",ilow);
if (ilow < ihigh) printf("%ld to %ld \t(%.1f)",ilow,ihigh,mean);
else if (ilow == ihigh) printf("= %ld",ilow);
else printf("No Values");
break;
@ -712,6 +719,8 @@ char *pt;
else printf("No Values");
break;
default:
break;
}
}
@ -720,161 +729,207 @@ char *pt;
int selectrec()
{
long int value, ty;
long int value, ty;
ty = DBFGetFieldInfo( hDBF, iselectitem, NULL, &iWidth, &iDecimals);
switch(ty)
{
case FTString:
puts("Invalid Item");
iselect=FALSE;
break;
case FTInteger:
value = DBFReadIntegerAttribute( hDBF, iRecord, iselectitem );
for (j = 0; j<selcount; j++)
{
if (selectvalues[j] == value)
if (iunselect) return(0); /* Keep this record */
else return(1); /* Skip this record */
}
break;
case FTDouble:
puts("Invalid Item");
iselect=FALSE;
break;
}
if (iunselect) return(1); /* Skip this record */
else return(0); /* Keep this record */
ty = DBFGetFieldInfo( hDBF, iselectitem, NULL, &iWidth, &iDecimals);
switch(ty) {
case FTString:
puts("Invalid Item");
iselect=FALSE;
break;
case FTInteger:
value = DBFReadIntegerAttribute( hDBF, iRecord, iselectitem );
for (j = 0; j<selcount; j++) {
if (selectvalues[j] == value) {
if (iunselect) {
return(0); /* Keep this record */
} else {
return(1); /* Skip this record */
}
}
}
break;
case FTDouble:
puts("Invalid Item");
iselect=FALSE;
break;
default:
break;
}
if (iunselect) {
return(1); /* Skip this record */
} else {
return(0); /* Keep this record */
}
}
int check_theme_bnd()
{
if ( (adfBoundsMin[0] >= cxmin) && (adfBoundsMax[0] <= cxmax) &&
(adfBoundsMin[1] >= cymin) && (adfBoundsMax[1] <= cymax) )
{ /** Theme is totally inside clip area **/
if (ierase) nEntities=0; /** SKIP THEME **/
else iclip=FALSE; /** WRITE THEME (Clip not needed) **/
(adfBoundsMin[1] >= cymin) && (adfBoundsMax[1] <= cymax) ) {
/** Theme is totally inside clip area **/
if (ierase) {
nEntities=0; /** SKIP THEME **/
} else {
iclip=FALSE; /** WRITE THEME (Clip not needed) **/
}
}
if ( ( (adfBoundsMin[0] < cxmin) && (adfBoundsMax[0] < cxmin) ) ||
( (adfBoundsMin[1] < cymin) && (adfBoundsMax[1] < cymin) ) ||
( (adfBoundsMin[0] > cxmax) && (adfBoundsMax[0] > cxmax) ) ||
( (adfBoundsMin[1] > cymax) && (adfBoundsMax[1] > cymax) ) )
{ /** Theme is totally outside clip area **/
if (ierase) iclip=FALSE; /** WRITE THEME (Clip not needed) **/
else nEntities=0; /** SKIP THEME **/
( (adfBoundsMin[1] > cymax) && (adfBoundsMax[1] > cymax) ) ) {
/** Theme is totally outside clip area **/
if (ierase) {
iclip=FALSE; /** WRITE THEME (Clip not needed) **/
} else {
nEntities=0; /** SKIP THEME **/
}
}
if (nEntities == 0)
if (nEntities == 0) {
puts("WARNING: Theme is outside the clip area."); /** SKIP THEME **/
}
return 0;
}
clip_boundary()
int clip_boundary()
{
int inside;
int prev_outside;
int i2;
int j2;
/*** FIRST check the boundary of the feature ***/
if ( ( (psCShape->dfXMin < cxmin) && (psCShape->dfXMax < cxmin) ) ||
( (psCShape->dfYMin < cymin) && (psCShape->dfYMax < cymin) ) ||
( (psCShape->dfXMin > cxmax) && (psCShape->dfXMax > cxmax) ) ||
( (psCShape->dfYMin > cymax) && (psCShape->dfYMax > cymax) ) )
{ /** Feature is totally outside clip area **/
if (ierase) return(1); /** WRITE RECORD **/
else return(0); /** SKIP RECORD **/
}
/*** FIRST check the boundary of the feature ***/
if ( ( (psCShape->dfXMin < cxmin) && (psCShape->dfXMax < cxmin) ) ||
( (psCShape->dfYMin < cymin) && (psCShape->dfYMax < cymin) ) ||
( (psCShape->dfXMin > cxmax) && (psCShape->dfXMax > cxmax) ) ||
( (psCShape->dfYMin > cymax) && (psCShape->dfYMax > cymax) ) ) {
/** Feature is totally outside clip area **/
if (ierase) {
return(1); /** WRITE RECORD **/
} else {
return(0); /** SKIP RECORD **/
}
}
if ( (psCShape->dfXMin >= cxmin) && (psCShape->dfXMax <= cxmax) &&
(psCShape->dfYMin >= cymin) && (psCShape->dfYMax <= cymax) )
{ /** Feature is totally inside clip area **/
if (ierase) return(0); /** SKIP RECORD **/
else return(1); /** WRITE RECORD **/
}
if ( (psCShape->dfXMin >= cxmin) && (psCShape->dfXMax <= cxmax) &&
(psCShape->dfYMin >= cymin) && (psCShape->dfYMax <= cymax) ) {
/** Feature is totally inside clip area **/
if (ierase) {
return(0); /** SKIP RECORD **/
} else {
return(1); /** WRITE RECORD **/
}
}
if (iinside)
{ /** INSIDE * Feature might touch the boundary or could be outside **/
if (ierase) return(1); /** WRITE RECORD **/
else return(0); /** SKIP RECORD **/
}
if (itouch)
{ /** TOUCH **/
if ( ( (psCShape->dfXMin <= cxmin) || (psCShape->dfXMax >= cxmax) ) &&
(psCShape->dfYMin >= cymin) && (psCShape->dfYMax <= cymax) )
{ /** Feature intersects the clip boundary only on the X axis **/
if (ierase) return(0); /** SKIP RECORD **/
else return(1); /** WRITE RECORD **/
}
if (iinside) { /** INSIDE * Feature might touch the boundary or could be outside **/
if (ierase) {
return(1); /** WRITE RECORD **/
} else {
return(0); /** SKIP RECORD **/
}
}
if ( (psCShape->dfXMin >= cxmin) && (psCShape->dfXMax <= cxmax) &&
( (psCShape->dfYMin <= cymin) || (psCShape->dfYMax >= cymax) ) )
{ /** Feature intersects the clip boundary only on the Y axis **/
if (ierase) return(0); /** SKIP RECORD **/
else return(1); /** WRITE RECORD **/
}
if (itouch) {
/** TOUCH **/
if ( ( (psCShape->dfXMin <= cxmin) || (psCShape->dfXMax >= cxmax) ) &&
(psCShape->dfYMin >= cymin) && (psCShape->dfYMax <= cymax) ) {
/** Feature intersects the clip boundary only on the X axis **/
if (ierase) {
return(0); /** SKIP RECORD **/
} else {
return(1); /** WRITE RECORD **/
}
}
if ( (psCShape->dfXMin >= cxmin) && (psCShape->dfXMax <= cxmax) &&
( (psCShape->dfYMin <= cymin) || (psCShape->dfYMax >= cymax) ) ) {
/** Feature intersects the clip boundary only on the Y axis **/
if (ierase) {
return(0); /** SKIP RECORD **/
} else {
return(1); /** WRITE RECORD **/
}
}
for( j2 = 0; j2 < psCShape->nVertices; j2++ )
{ /** At least one vertex must be inside the clip boundary **/
if ( (psCShape->padfX[j2] >= cxmin && psCShape->padfX[j2] <= cxmax) ||
(psCShape->padfY[j2] >= cymin && psCShape->padfY[j2] <= cymax) )
if (ierase) return(0); /** SKIP RECORD **/
else return(1); /** WRITE RECORD **/
}
for( j2 = 0; j2 < psCShape->nVertices; j2++ ) {
/** At least one vertex must be inside the clip boundary **/
if ( (psCShape->padfX[j2] >= cxmin && psCShape->padfX[j2] <= cxmax) ||
(psCShape->padfY[j2] >= cymin && psCShape->padfY[j2] <= cymax) ) {
if (ierase) {
return(0); /** SKIP RECORD **/
} else {
return(1); /** WRITE RECORD **/
}
}
}
/** All vertices are outside the clip boundary **/
if (ierase) return(1); /** WRITE RECORD **/
else return(0); /** SKIP RECORD **/
} /** End TOUCH **/
/** All vertices are outside the clip boundary **/
if (ierase) {
return(1); /** WRITE RECORD **/
} else {
return(0); /** SKIP RECORD **/
}
} /** End TOUCH **/
if (icut)
{ /** CUT **/
/*** Check each vertex in the feature with the Boundary and "CUT" ***/
/*** THIS CODE WAS NOT COMPLETED! READ NOTE AT THE BOTTOM ***/
i2=0;
prev_outside=FALSE;
for( j2 = 0; j2 < psCShape->nVertices; j2++ )
{
inside = psCShape->padfX[j2] >= cxmin && psCShape->padfX[j2] <= cxmax &&
psCShape->padfY[j2] >= cymin && psCShape->padfY[j2] <= cymax ;
if (icut) {
/** CUT **/
/*** Check each vertex in the feature with the Boundary and "CUT" ***/
/*** THIS CODE WAS NOT COMPLETED! READ NOTE AT THE BOTTOM ***/
i2=0;
prev_outside=FALSE;
for( j2 = 0; j2 < psCShape->nVertices; j2++ ) {
inside = psCShape->padfX[j2] >= cxmin && psCShape->padfX[j2] <= cxmax &&
psCShape->padfY[j2] >= cymin && psCShape->padfY[j2] <= cymax ;
if (ierase) inside=(! inside);
if (inside)
{
if (i2 != j2)
{
if (prev_outside)
{
/*** AddIntersection(i2); /*** Add intersection ***/
prev_outside=FALSE;
}
psCShape->padfX[i2]=psCShape->padfX[j2]; /** move vertex **/
psCShape->padfY[i2]=psCShape->padfY[j2];
}
i2++;
} else {
if ( (! prev_outside) && (j2 > 0) )
{
/*** AddIntersection(i2); /*** Add intersection (Watch out for j2==i2-1) ***/
/*** Also a polygon may overlap twice and will split into a several parts ***/
prev_outside=TRUE;
}
}
}
if (ierase) {
inside=(! inside);
}
if (inside) {
if (i2 != j2) {
if (prev_outside) {
/*** Add intersection ***/
prev_outside=FALSE;
}
psCShape->padfX[i2]=psCShape->padfX[j2]; /** move vertex **/
psCShape->padfY[i2]=psCShape->padfY[j2];
}
i2++;
} else {
if ( (! prev_outside) && (j2 > 0) ) {
/*** Add intersection (Watch out for j2==i2-1) ***/
/*** Also a polygon may overlap twice and will split into a several parts ***/
prev_outside=TRUE;
}
}
}
printf("Vertices:%d OUT:%d Number of Parts:%d\n",
psCShape->nVertices,i2, psCShape->nParts );
psCShape->nVertices = i2;
psCShape->nVertices = i2;
if (i2 < 2) return(0); /** SKIP RECORD **/
/*** (WE ARE NOT CREATING INTERESECTIONS and some lines could be reduced to one point) **/
if (i2 < 2) {
return(0); /** SKIP RECORD **/
}
if (i2 == 0) return(0); /** SKIP RECORD **/
else return(1); /** WRITE RECORD **/
} /** End CUT **/
/*** (WE ARE NOT CREATING INTERESECTIONS and some lines could be reduced to one point) **/
if (i2 == 0) {
return(0); /** SKIP RECORD **/
} else {
return(1); /** WRITE RECORD **/
}
} /** End CUT **/
return -1;
}
@ -909,31 +964,29 @@ int j,i;
return(0);
}
#define NKEYS (sizeof(unitkeytab) / sizeof(struct unitkey))
findunit(unit)
char *unit;
{
int findunit(char *unit)
{
struct unitkey {
char *name;
double value;
} unitkeytab[] = {
"CM", 39.37,
"CENTIMETER", 39.37,
"CENTIMETERS", 39.37, /** # of inches * 100 in unit **/
"METER", 3937,
"METERS", 3937,
"KM", 3937000,
"KILOMETER", 3937000,
"KILOMETERS", 3937000,
"INCH", 100,
"INCHES", 100,
"FEET", 1200,
"FOOT", 1200,
"YARD", 3600,
"YARDS", 3600,
"MILE", 6336000,
"MILES", 6336000
{ "CM", 39.37 },
{ "CENTIMETER", 39.37 },
{ "CENTIMETERS", 39.37 }, /** # of inches * 100 in unit **/
{ "METER", 3937 },
{ "METERS", 3937 },
{ "KM", 3937000 },
{ "KILOMETER", 3937000 },
{ "KILOMETERS", 3937000 },
{ "INCH", 100 },
{ "INCHES", 100 },
{ "FEET", 1200 },
{ "FOOT", 1200 },
{ "YARD", 3600 },
{ "YARDS", 3600 },
{ "MILE", 6336000 },
{ "MILES", 6336000 }
};
double unitfactor=0;

View file

@ -529,49 +529,57 @@ VpfTable::read_double (istream &input) const
short
VpfTable::make_short (char buf[2]) const
{
if (_system_byte_order == _file_byte_order) {
return *((short *)buf);
} else {
char out[2];
swap2(buf, out);
return *((short *)out);
}
if (_system_byte_order == _file_byte_order) {
return *((short *)buf);
} else {
char out[2];
short *out_short = (short *)out;
swap2(buf, out);
return *out_short;
}
}
int
VpfTable::make_int (char buf[4]) const
{
if (_system_byte_order == _file_byte_order) {
return *((int *)buf);
} else {
char out[4];
swap4(buf, out);
return *((int *)out);
}
if (_system_byte_order == _file_byte_order) {
return *((int *)buf);
} else {
char out[4];
int *int_out = (int *)out;
swap4(buf, out);
return *int_out;
}
}
float
VpfTable::make_float (char buf[4]) const
{
if (_system_byte_order == _file_byte_order) {
return *((float *)buf);
} else {
char out[4];
swap4(buf, out);
return *((float *)out);
}
if (_system_byte_order == _file_byte_order) {
return *((float *)buf);
} else {
char out[4];
float *float_out = (float *)out;
swap4(buf, out);
return *float_out;
}
}
double
VpfTable::make_double (char buf[8]) const
{
if (_system_byte_order == _file_byte_order) {
return *((double *)buf);
} else {
char out[8];
swap8(buf, out);
return *((double *)out);
}
if (_system_byte_order == _file_byte_order) {
return *((double *)buf);
} else {
char out[8];
double *double_out = (double *)out;
swap8(buf, out);
return *double_out;
}
}

View file

@ -485,37 +485,41 @@ VpfValue::convertType (char rawType)
ostream &
operator<< (ostream &output, const VpfValue &value)
{
switch (value.getType()) {
case VpfValue::TEXT:
output << value.getText();
break;
case VpfValue::INT:
output << value.getInt();
break;
case VpfValue::REAL:
output << value.getReal();
break;
case VpfValue::POINTS: {
int nPoints = value.getElementCount();
for (int i = 0; i < nPoints; i++) {
if (i > 0)
output << ',';
output << '{' << value.getPoint(i).x << ','
<< value.getPoint(i).y << ',' << value.getPoint(i).z << '}';
switch (value.getType()) {
case VpfValue::TEXT:
output << value.getText();
break;
case VpfValue::INT:
output << value.getInt();
break;
case VpfValue::REAL:
output << value.getReal();
break;
case VpfValue::POINTS: {
int nPoints = value.getElementCount();
for (int i = 0; i < nPoints; i++) {
if (i > 0) {
output << ',';
}
output << '{' << value.getPoint(i).x << ','
<< value.getPoint(i).y << ','
<< value.getPoint(i).z << '}';
}
break;
}
case VpfValue::DATE:
output << value.getDate(); // FIXME
break;
case VpfValue::CROSSREF:
output << value.getCrossRef().current_tile_key << ','
<< value.getCrossRef().next_tile_id << ','
<< value.getCrossRef().next_tile_key;
break;
default:
break;
}
break;
}
case VpfValue::DATE:
output << value.getDate(); // FIXME
break;
case VpfValue::CROSSREF:
output << value.getCrossRef().current_tile_key << ','
<< value.getCrossRef().next_tile_id << ','
<< value.getCrossRef().next_tile_key;
break;
}
return output;
return output;
}
// end of value.cxx

View file

@ -79,33 +79,32 @@ struct SimpleRasterTransformerInfo {
double col_step, row_step;
};
int SimpleRasterTransformer(void *pTransformerArg,
int bDstToSrc, int nPointCount,
int SimpleRasterTransformer(void *pTransformerArg,
int bDstToSrc, int nPointCount,
double *x, double *y, double *z, int *panSuccess )
{
SimpleRasterTransformerInfo* info=(SimpleRasterTransformerInfo*)pTransformerArg;
SimpleRasterTransformerInfo* info = (SimpleRasterTransformerInfo*)pTransformerArg;
int success;
if (bDstToSrc) {
/* transform destination -> source */
for (int i=0;i<nPointCount;i++) {
x[i]=info->x0+info->col_step*x[i];
y[i]=info->y0+info->row_step*y[i];
for (int i = 0; i < nPointCount; i++) {
x[i] = info->x0 + info->col_step * x[i];
y[i] = info->y0 + info->row_step * y[i];
}
success=info->pfnTransformer(info->pTransformerArg,
bDstToSrc,nPointCount,
x,y,z,panSuccess);
success = info->pfnTransformer(info->pTransformerArg,
bDstToSrc, nPointCount,
x, y, z, panSuccess);
} else {
success=info->pfnTransformer(info->pTransformerArg,
bDstToSrc,nPointCount,
x,y,z,panSuccess);
for (int i=0;i<nPointCount;i++) {
if (!panSuccess[i]) {
success = info->pfnTransformer(info->pTransformerArg,
bDstToSrc, nPointCount,
x, y, z, panSuccess);
for (int i = 0; i < nPointCount; i++) {
if (!panSuccess[i])
continue;
}
x[i]=(x[i]-info->x0)/info->col_step;
y[i]=(y[i]-info->y0)/info->row_step;
x[i] = (x[i] - info->x0) / info->col_step;
y[i] = (y[i] - info->y0) / info->row_step;
}
}
return success;
@ -113,178 +112,183 @@ int SimpleRasterTransformer(void *pTransformerArg,
class ImageInfo {
public:
ImageInfo(GDALDataset *dataset);
void GetBounds(double &n, double &s, double &e, double &w) const {
n=north;
s=south;
e=east;
w=west;
}
const char* GetDescription() const {
return dataset->GetDescription();
}
void GetDataChunk(int *buffer,
double x, double y,
double colstep, double rowstep,
int w, int h,
int srcband=1, int nodata=-32768);
ImageInfo(GDALDataset *dataset);
void GetBounds(double &n, double &s, double &e, double &w) const
{
n = north;
s = south;
e = east;
w = west;
}
const char* GetDescription() const
{
return dataset->GetDescription();
}
void GetDataChunk(int *buffer,
double x, double y,
double colstep, double rowstep,
int w, int h,
int srcband = 1, int nodata = -32768);
protected:
/* The dataset */
GDALDataset *dataset;
/* Source spatial reference system */
OGRSpatialReference srs;
/* Coordinate transformation pixel -> geographic */
double geoXfrm[6];
/* Coordinate transformation to WGS84 */
OGRCoordinateTransformation *wgs84xform;
/* geographical edge coordinates in CCW order, WGS84 */
double geoX[4],geoY[4];
/* bounding box in WGS84 */
double north,south,east,west;
/* The dataset */
GDALDataset *dataset;
/* Source spatial reference system */
OGRSpatialReference srs;
/* Coordinate transformation pixel -> geographic */
double geoXfrm[6];
/* Coordinate transformation to WGS84 */
OGRCoordinateTransformation *wgs84xform;
/* geographical edge coordinates in CCW order, WGS84 */
double geoX[4], geoY[4];
/* bounding box in WGS84 */
double north, south, east, west;
};
ImageInfo::ImageInfo(GDALDataset *dataset):
dataset(dataset),
srs(dataset->GetProjectionRef())
ImageInfo::ImageInfo(GDALDataset *dataset) :
dataset(dataset),
srs(dataset->GetProjectionRef())
{
OGRSpatialReference wgs84SRS;
wgs84SRS.SetWellKnownGeogCS( "EPSG:4326" );
/* Determine the bounds of the input file in WGS84 */
int w=dataset->GetRasterXSize();
int h=dataset->GetRasterYSize();
if (dataset->GetGeoTransform(geoXfrm)!=CE_None) {
SG_LOG(SG_GENERAL, SG_ALERT,
"Could not determine transform matrix for dataset "
"'" << dataset->GetDescription() << "'"
":" << CPLGetLastErrorMsg());
exit(1);
int w = dataset->GetRasterXSize();
int h = dataset->GetRasterYSize();
if (dataset->GetGeoTransform(geoXfrm) != CE_None) {
SG_LOG(SG_GENERAL, SG_ALERT,
"Could not determine transform matrix for dataset "
"'" << dataset->GetDescription() << "'"
":" << CPLGetLastErrorMsg());
exit(1);
}
/* create points in CCW order */
geoX[0]=geoXfrm[0]+0*geoXfrm[1]+0*geoXfrm[2];
geoX[1]=geoXfrm[0]+0*geoXfrm[1]+h*geoXfrm[2];
geoX[2]=geoXfrm[0]+w*geoXfrm[1]+h*geoXfrm[2];
geoX[3]=geoXfrm[0]+w*geoXfrm[1]+0*geoXfrm[2];
geoY[0]=geoXfrm[3]+0*geoXfrm[4]+0*geoXfrm[5];
geoY[1]=geoXfrm[3]+0*geoXfrm[4]+h*geoXfrm[5];
geoY[2]=geoXfrm[3]+w*geoXfrm[4]+h*geoXfrm[5];
geoY[3]=geoXfrm[3]+w*geoXfrm[4]+0*geoXfrm[5];
const char* projRef=dataset->GetProjectionRef();
srs=OGRSpatialReference(projRef);
geoX[0] = geoXfrm[0] + 0 * geoXfrm[1] + 0 * geoXfrm[2];
geoX[1] = geoXfrm[0] + 0 * geoXfrm[1] + h * geoXfrm[2];
geoX[2] = geoXfrm[0] + w * geoXfrm[1] + h * geoXfrm[2];
geoX[3] = geoXfrm[0] + w * geoXfrm[1] + 0 * geoXfrm[2];
geoY[0] = geoXfrm[3] + 0 * geoXfrm[4] + 0 * geoXfrm[5];
geoY[1] = geoXfrm[3] + 0 * geoXfrm[4] + h * geoXfrm[5];
geoY[2] = geoXfrm[3] + w * geoXfrm[4] + h * geoXfrm[5];
geoY[3] = geoXfrm[3] + w * geoXfrm[4] + 0 * geoXfrm[5];
const char* projRef = dataset->GetProjectionRef();
srs = OGRSpatialReference(projRef);
wgs84xform = OGRCreateCoordinateTransformation( &srs, &wgs84SRS );
if (!wgs84xform->Transform(4,geoX,geoY)) {
SG_LOG(SG_GENERAL, SG_ALERT,
"Could not transform edge points of dataset "
"'" << dataset->GetDescription() << "'"
":" << CPLGetLastErrorMsg());
exit(1);
if (!wgs84xform->Transform(4, geoX, geoY)) {
SG_LOG(SG_GENERAL, SG_ALERT,
"Could not transform edge points of dataset "
"'" << dataset->GetDescription() << "'"
":" << CPLGetLastErrorMsg());
exit(1);
}
east=west=geoX[0];
north=south=geoY[0];
for (int j=1;j<4;j++) {
north=std::max(north,geoY[j]);
south=std::min(south,geoY[j]);
east =std::max(east ,geoX[j]);
west =std::min(west ,geoX[j]);
east = west = geoX[0];
north = south = geoY[0];
for (int j = 1; j < 4; j++) {
north = std::max(north, geoY[j]);
south = std::min(south, geoY[j]);
east = std::max(east, geoX[j]);
west = std::min(west, geoX[j]);
}
SG_LOG(SG_GENERAL, SG_INFO,
"INFO: Bounds for '" << dataset->GetDescription() << "' are"
" n=" << north << " s=" << south <<
" e=" << east << " w=" << west);
"INFO: Bounds for '" << dataset->GetDescription() << "' are"
" n=" << north << " s=" << south <<
" e=" << east << " w=" << west);
}
void ImageInfo::GetDataChunk(int *buffer,
double x, double y,
double colstep, double rowstep,
int w, int h,
int srcband, int nodata) {
int srcband, int nodata)
{
OGRSpatialReference wgs84SRS;
wgs84SRS.SetWellKnownGeogCS( "EPSG:4326" );
char* wgs84WKT;
wgs84SRS.exportToWkt(&wgs84WKT);
/* Setup a raster transformation from WGS84 to raster coordinates of the array files */
SimpleRasterTransformerInfo xformData;
xformData.pTransformerArg=GDALCreateGenImgProjTransformer(
dataset,NULL,
NULL,wgs84WKT,
FALSE,
0.0,
1);
xformData.pfnTransformer=GDALGenImgProjTransform;
xformData.x0=x;
xformData.y0=y;
xformData.col_step=colstep;
xformData.row_step=rowstep;
xformData.pTransformerArg = GDALCreateGenImgProjTransformer(
dataset, NULL,
NULL, wgs84WKT,
FALSE,
0.0,
1);
xformData.pfnTransformer = GDALGenImgProjTransform;
xformData.x0 = x;
xformData.y0 = y;
xformData.col_step = colstep;
xformData.row_step = rowstep;
// TODO: check if this image can actually cover part of the chunk
/* establish the full source to target transformation */
GDALWarpOptions *psWarpOptions = GDALCreateWarpOptions();
int srcBandNumbers[]={srcband};
int dstBandNumbers[]={1};
double dstNodata[]={nodata};
int srcBandNumbers[] = { srcband };
int dstBandNumbers[] = { 1 };
double dstNodata[] = { nodata };
double srcNodataReal[1];
double srcNodataImag[]={0.0};
double srcNodataImag[] = { 0.0 };
int srcHasNodataValue;
srcNodataReal[0]=dataset->GetRasterBand(srcband)->GetNoDataValue(&srcHasNodataValue);
psWarpOptions->hSrcDS=dataset;
psWarpOptions->hDstDS=NULL;
psWarpOptions->nBandCount=1;
psWarpOptions->panSrcBands=srcBandNumbers;
psWarpOptions->panDstBands=dstBandNumbers;
psWarpOptions->nSrcAlphaBand=0;
psWarpOptions->nDstAlphaBand=0;
psWarpOptions->padfSrcNoDataReal=(srcHasNodataValue?srcNodataReal:NULL);
psWarpOptions->padfSrcNoDataImag=(srcHasNodataValue?srcNodataImag:NULL);
psWarpOptions->padfDstNoDataReal=dstNodata;
srcNodataReal[0] = dataset->GetRasterBand(srcband)->GetNoDataValue(&srcHasNodataValue);
psWarpOptions->hSrcDS = dataset;
psWarpOptions->hDstDS = NULL;
psWarpOptions->nBandCount = 1;
psWarpOptions->panSrcBands = srcBandNumbers;
psWarpOptions->panDstBands = dstBandNumbers;
psWarpOptions->nSrcAlphaBand = 0;
psWarpOptions->nDstAlphaBand = 0;
psWarpOptions->padfSrcNoDataReal = (srcHasNodataValue ? srcNodataReal : NULL);
psWarpOptions->padfSrcNoDataImag = (srcHasNodataValue ? srcNodataImag : NULL);
psWarpOptions->padfDstNoDataReal = dstNodata;
psWarpOptions->eResampleAlg = GRA_Bilinear;
psWarpOptions->eWorkingDataType = GDT_Int32;
psWarpOptions->pfnTransformer=SimpleRasterTransformer;
psWarpOptions->pTransformerArg=&xformData;
psWarpOptions->pfnTransformer = SimpleRasterTransformer;
psWarpOptions->pTransformerArg = &xformData;
GDALWarpOperation oOperation;
oOperation.Initialize( psWarpOptions );
/* do the warp */
if (oOperation.WarpRegionToBuffer(0,0,w,h,buffer,GDT_Int32)!=CE_None) {
if (oOperation.WarpRegionToBuffer(0, 0, w, h, buffer, GDT_Int32) != CE_None) {
SG_LOG(SG_GENERAL, SG_ALERT,
"Could not warp to buffer on dataset '" << GetDescription() << "'"
":" << CPLGetLastErrorMsg());
"Could not warp to buffer on dataset '" << GetDescription() << "'"
":" << CPLGetLastErrorMsg());
}
/* clean up */
psWarpOptions->panSrcBands=NULL;
psWarpOptions->panDstBands=NULL;
psWarpOptions->padfSrcNoDataReal=NULL;
psWarpOptions->padfSrcNoDataImag=NULL;
psWarpOptions->padfDstNoDataReal=NULL;
psWarpOptions->panSrcBands = NULL;
psWarpOptions->panDstBands = NULL;
psWarpOptions->padfSrcNoDataReal = NULL;
psWarpOptions->padfSrcNoDataImag = NULL;
psWarpOptions->padfDstNoDataReal = NULL;
GDALDestroyGenImgProjTransformer( xformData.pTransformerArg );
GDALDestroyWarpOptions( psWarpOptions );
}
@ -294,117 +298,117 @@ void write_bucket(const string& work_dir, SGBucket bucket,
int min_x, int min_y,
int span_x, int span_y,
int col_step, int row_step,
bool compress=true) {
SGPath path(work_dir);
path.append(bucket.gen_base_path());
path.create_dir( 0755 );
bool compress = true)
{
SGPath path(work_dir);
string array_file = path.str() + "/" + bucket.gen_index_str() + ".arr";
FILE *fp;
if ( (fp = fopen(array_file.c_str(), "w")) == NULL ) {
SG_LOG(SG_GENERAL, SG_ALERT, "cannot open " << array_file << " for writing!");
exit(-1);
}
fprintf( fp, "%d %d\n", min_x, min_y );
fprintf( fp, "%d %d %d %d\n",
span_x + 1, col_step,
span_y + 1, row_step );
int k=0;
for ( int x = 0; x <= span_x; ++x ) {
for ( int y = 0; y <= span_y; ++y ) {
fprintf( fp, "%d ", buffer[ y * span_x + x ] );
}
fprintf( fp, "\n" );
}
fclose(fp);
if ( compress ) {
string command = "gzip --best -f " + array_file;
system( command.c_str() );
}
path.append(bucket.gen_base_path());
path.create_dir( 0755 );
string array_file = path.str() + "/" + bucket.gen_index_str() + ".arr";
FILE *fp;
if ( (fp = fopen(array_file.c_str(), "w")) == NULL ) {
SG_LOG(SG_GENERAL, SG_ALERT, "cannot open " << array_file << " for writing!");
exit(-1);
}
fprintf( fp, "%d %d\n", min_x, min_y );
fprintf( fp, "%d %d %d %d\n",
span_x + 1, col_step,
span_y + 1, row_step );
for ( int x = 0; x <= span_x; ++x ) {
for ( int y = 0; y <= span_y; ++y )
fprintf( fp, "%d ", buffer[ y * span_x + x ] );
fprintf( fp, "\n" );
}
fclose(fp);
if ( compress ) {
string command = "gzip --best -f " + array_file;
system( command.c_str() );
}
}
void process_bucket(const string& work_dir, SGBucket bucket,
ImageInfo* images[], int imagecount,
bool forceWrite=false) {
double clat,clon;
double bnorth,bsouth,beast,bwest;
clat=bucket.get_center_lat();
clon=bucket.get_center_lon();
bnorth=clat+bucket.get_height()/2.0;
bsouth=clat-bucket.get_height()/2.0;
beast =clon+bucket.get_width()/2.0;
bwest =clon-bucket.get_width()/2.0;
SG_LOG(SG_GENERAL, SG_INFO, "processing bucket " << bucket << "(" << bucket.gen_index() << ") n=" << bnorth << " s=" << bsouth << " e=" << beast << " w=" << bwest);
/* Get the data from the input datasets... */
int min_x, min_y, span_x, span_y;
min_x = (int)(bwest*3600.0);
min_y = (int)(bsouth*3600.0);
// TODO: Make other resolutions possible as well
int col_step=3, row_step=3;
span_x=bucket.get_width()*3600/col_step;
span_y=bucket.get_height()*3600/row_step;
int cellcount=(span_x+1)*(span_y+1);
boost::scoped_array<int> buffer(new int[cellcount]);
::memset(buffer.get(),-1,(span_x+1)*(span_y+1)*sizeof(int));
for (int i=0;i<imagecount;i++) {
double inorth,isouth,ieast,iwest;
images[i]->GetBounds(inorth,isouth,ieast,iwest);
images[i]->GetDataChunk(buffer.get(),
bwest, bsouth,
col_step/3600.0, row_step/3600.0,
span_x+1, span_y+1);
}
/* ...check the amount of undefined cells... */
int nodataCellCount=0;
for (int i=0;i<cellcount;i++) {
if (buffer[i]==-32768) {
nodataCellCount++;
}
}
const double nodataPercLimit=5.0;
double nodataPerc=100.0*nodataCellCount/cellcount;
if (nodataCellCount>0) {
SG_LOG(SG_GENERAL, SG_INFO, " " << nodataCellCount << " cells are not covered with data (" << nodataPerc << "% of cells)");
}
if (nodataPerc>nodataPercLimit) {
SG_LOG(SG_GENERAL, SG_INFO, " there is not enough data available to cover this cell (limit for non-covered cells is " << nodataPercLimit <<"%)");
/* don't write out if not forced to */
if (!forceWrite)
return;
}
/* ...and write it out */
write_bucket(work_dir, bucket,
buffer.get(),
min_x, min_y,
span_x, span_y,
col_step, row_step);
bool forceWrite = false)
{
double clat, clon;
double bnorth, bsouth, beast, bwest;
clat = bucket.get_center_lat();
clon = bucket.get_center_lon();
bnorth = clat + bucket.get_height() / 2.0;
bsouth = clat - bucket.get_height() / 2.0;
beast = clon + bucket.get_width() / 2.0;
bwest = clon - bucket.get_width() / 2.0;
SG_LOG(SG_GENERAL, SG_INFO, "processing bucket " << bucket << "(" << bucket.gen_index() << ") n=" << bnorth << " s=" << bsouth << " e=" << beast << " w=" << bwest);
/* Get the data from the input datasets... */
int min_x, min_y, span_x, span_y;
min_x = (int)(bwest * 3600.0);
min_y = (int)(bsouth * 3600.0);
// TODO: Make other resolutions possible as well
int col_step = 3, row_step = 3;
span_x = bucket.get_width() * 3600 / col_step;
span_y = bucket.get_height() * 3600 / row_step;
int cellcount = (span_x + 1) * (span_y + 1);
boost::scoped_array<int> buffer(new int[cellcount]);
::memset(buffer.get(), -1, (span_x + 1) * (span_y + 1) * sizeof(int));
for (int i = 0; i < imagecount; i++) {
double inorth, isouth, ieast, iwest;
images[i]->GetBounds(inorth, isouth, ieast, iwest);
images[i]->GetDataChunk(buffer.get(),
bwest, bsouth,
col_step / 3600.0, row_step / 3600.0,
span_x + 1, span_y + 1);
}
/* ...check the amount of undefined cells... */
int nodataCellCount = 0;
for (int i = 0; i < cellcount; i++)
if (buffer[i] == -32768)
nodataCellCount++;
const double nodataPercLimit = 5.0;
double nodataPerc = 100.0 * nodataCellCount / cellcount;
if (nodataCellCount > 0)
SG_LOG(SG_GENERAL, SG_INFO, " " << nodataCellCount << " cells are not covered with data (" << nodataPerc << "% of cells)");
if (nodataPerc > nodataPercLimit) {
SG_LOG(SG_GENERAL, SG_INFO, " there is not enough data available to cover this cell (limit for non-covered cells is " << nodataPercLimit << "%)");
/* don't write out if not forced to */
if (!forceWrite)
return;
}
/* ...and write it out */
write_bucket(work_dir, bucket,
buffer.get(),
min_x, min_y,
span_x, span_y,
col_step, row_step);
}
int main(int argc, const char **argv) {
int main(int argc, const char **argv)
{
sglog().setLogLevels( SG_ALL, SG_INFO );
if ( argc < 3 ) {
SG_LOG(SG_GENERAL, SG_ALERT,
"Usage " << argv[0] << " <work_dir> <datasetname...> [-- <bucket-idx> ...]");
exit(-1);
SG_LOG(SG_GENERAL, SG_ALERT,
"Usage " << argv[0] << " <work_dir> <datasetname...> [-- <bucket-idx> ...]");
exit(-1);
}
SGPath work_dir( argv[1] );
@ -413,61 +417,59 @@ int main(int argc, const char **argv) {
GDALAllRegister();
int datasetcount=0,tilecount=0;
int datasetcount = 0, tilecount = 0;
int dashpos;
for (dashpos=2;dashpos<argc;dashpos++) {
if (!strcmp(argv[dashpos],"--")) {
break;
}
for (dashpos = 2; dashpos < argc; dashpos++)
if (!strcmp(argv[dashpos], "--"))
break;
datasetcount = dashpos - 2;
tilecount = (dashpos == argc ? 0 : argc - dashpos - 1);
if (datasetcount == 0) {
SG_LOG(SG_GENERAL, SG_ALERT,
"No data sets supplied. Must provide at least one dataset.");
exit(1);
}
datasetcount=dashpos-2;
tilecount=(dashpos==argc?0:argc-dashpos-1);
const char** tilenames = argv + dashpos + 1;
const char** datasetnames = argv + 2;
if (datasetcount==0) {
SG_LOG(SG_GENERAL, SG_ALERT,
"No data sets supplied. Must provide at least one dataset.");
exit(1);
}
const char** tilenames=argv+dashpos+1;
const char** datasetnames=argv+2;
boost::scoped_array<ImageInfo *> images( new ImageInfo *[datasetcount] );
double north=-1000,south=1000,east=-1000,west=1000;
double north = -1000, south = 1000, east = -1000, west = 1000;
// TODO: allow specification of bounds by user
/*
* Step 1: Open all provided datasets and determine their bounds in WGS84.
*/
for (int i=0;i<datasetcount;i++) {
GDALDataset* dataset;
dataset=(GDALDataset *)GDALOpenShared(datasetnames[i],GA_ReadOnly);
if (dataset==NULL) {
SG_LOG(SG_GENERAL, SG_ALERT,
"Could not open dataset '" << datasetnames[i] << "'"
":" << CPLGetLastErrorMsg());
exit(1);
}
images[i]=new ImageInfo(dataset);
double inorth,isouth,ieast,iwest;
images[i]->GetBounds(inorth,isouth,ieast,iwest);
north=std::max(north,inorth);
south=std::min(south,isouth);
east =std::max(east ,ieast );
west =std::min(west ,iwest );
for (int i = 0; i < datasetcount; i++) {
GDALDataset* dataset;
dataset = (GDALDataset*)GDALOpenShared(datasetnames[i], GA_ReadOnly);
if (dataset == NULL) {
SG_LOG(SG_GENERAL, SG_ALERT,
"Could not open dataset '" << datasetnames[i] << "'"
":" << CPLGetLastErrorMsg());
exit(1);
}
images[i] = new ImageInfo(dataset);
double inorth, isouth, ieast, iwest;
images[i]->GetBounds(inorth, isouth, ieast, iwest);
north = std::max(north, inorth);
south = std::min(south, isouth);
east = std::max(east, ieast );
west = std::min(west, iwest );
}
SG_LOG(SG_GENERAL, SG_INFO, "Complete bounds n=" << north << " s=" << south << " e=" << east << " w=" << west);
/*
* Step 2: If no tiles were specified, go through all tiles contained in
* the common bounds of all datasets and find those which have
@ -476,25 +478,25 @@ int main(int argc, const char **argv) {
* all of them. Warn if no sufficient coverage (non-null pixels) is
* available.
*/
if (tilecount==0) {
if (tilecount == 0) {
/*
* No tiles were specified, so we determine the common bounds of all
* specified datasets and check all the tiles contained in them.
*/
SGBucket start(west,south),end(east,north);
int dx,dy;
SGBucket start(west, south), end(east, north);
int dx, dy;
sgBucketDiff(start, end, &dx, &dy);
SG_LOG(SG_GENERAL, SG_INFO, "dx=" << dx << " dy=" << dy);
for (int x=0;x<=dx;x++) {
for (int y=0;y<=dy;y++) {
SGBucket bucket=sgBucketOffset(west,south,x,y);
process_bucket(work_dir.str(),bucket,images.get(),datasetcount);
for (int x = 0; x <= dx; x++) {
for (int y = 0; y <= dy; y++) {
SGBucket bucket = sgBucketOffset(west, south, x, y);
process_bucket(work_dir.str(), bucket, images.get(), datasetcount);
}
}
} else {
@ -502,13 +504,13 @@ int main(int argc, const char **argv) {
* Tiles were specified, so process them and warn if not enough
* data is available, but write them in any case.
*/
for (int i=0;i<tilecount;i++) {
for (int i = 0; i < tilecount; i++) {
SGBucket bucket(atol(tilenames[i]));
process_bucket(work_dir.str(),bucket,images.get(),datasetcount,true);
process_bucket(work_dir.str(), bucket, images.get(), datasetcount, true);
}
}
return 0;
}

View file

@ -139,7 +139,7 @@ static unsigned int timestamp = 0;
static void overEdge(Edge *e, edge_callback fn, void *closure)
{
if( e->token != timestamp )
if( e->token != (int)timestamp )
{
e->token = timestamp;
e->Sym()->token = timestamp;
@ -247,37 +247,42 @@ Edge *Subdivision::locate(const Vec2& x, Edge *start)
real to = triArea(x, eo->Dest(), eo->Org());
real td = triArea(x, ed->Dest(), ed->Org());
if (td>0) // x is below ed
if (to>0 || to==0 && t==0) {// x is interior, or origin endpoint
if ( td > 0 ) { // x is below ed
if ( (to > 0) || (to==0 && t==0) ) { // x is interior, or origin endpoint
startingEdge = e;
return e;
}
else { // x is below ed, below eo
else { // x is below ed, below eo
t = to;
e = eo;
}
else // x is on or above ed
if (to>0) // x is above eo
if (td==0 && t==0) { // x is destination endpoint
}
else { // x is on or above ed
if (to>0) { // x is above eo
if (td==0 && t==0) { // x is destination endpoint
startingEdge = e;
return e;
}
else { // x is on or above ed and above eo
else { // x is on or above ed and above eo
t = td;
e = ed;
}
else // x is on or below eo
if (t==0 && !leftOf(eo->Dest(), e))
}
else { // x is on or below eo
if (t==0 && !leftOf(eo->Dest(), e)) {
// x on e but subdiv. is to right
e = e->Sym();
else if (rand()&1) { // x is on or above ed and
t = to; // on or below eo; step randomly
}
else if (rand()&1) { // x is on or above ed and
t = to; // on or below eo; step randomly
e = eo;
}
else {
t = td;
e = ed;
}
}
}
}
}
@ -372,7 +377,7 @@ void Subdivision::optimize(Vec2& x, Edge *s)
do {
Edge *e = spoke->Lnext();
Edge *t = e->Oprev();
// Edge *t = e->Oprev();
if( isInterior(e) && shouldSwap(x, e) )
swap(e);