Compile warnings cleanup round 1
This commit is contained in:
parent
48774e19e8
commit
27c31404ca
12 changed files with 1369 additions and 1407 deletions
src
Airports/GenAirports
Lib
Geometry
Polygon
e00
poly2tri
shapelib
vpf
Prep
|
@ -605,7 +605,7 @@ void build_airport( string airport_id, float alt_m,
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
/* Ralf Gerlich: Generate Taxiways in specified order from bottom to top */
|
/* 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 );
|
SG_LOG( SG_GENERAL, SG_DEBUG, "generating " << i );
|
||||||
build_runway( taxiways[i], alt_m,
|
build_runway( taxiways[i], alt_m,
|
||||||
&rwy_polys, &texparams, &accum,
|
&rwy_polys, &texparams, &accum,
|
||||||
|
@ -970,7 +970,7 @@ void build_airport( string airport_id, float alt_m,
|
||||||
tri_materials.push_back( "Grass" );
|
tri_materials.push_back( "Grass" );
|
||||||
|
|
||||||
std::vector < SGGeod > geodNodes;
|
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];
|
Point3D node = nodes.get_node_list()[j];
|
||||||
geodNodes.push_back( SGGeod::fromDegM( node.x(), node.y(), node.z() ) );
|
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" );
|
strip_materials.push_back( "Grass" );
|
||||||
|
|
||||||
std::vector < SGGeod > geodNodes;
|
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];
|
Point3D node = nodes.get_node_list()[j];
|
||||||
geodNodes.push_back( SGGeod::fromDegM( node.x(), node.y(), node.z() ) );
|
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 );
|
wgs84_nodes.push_back( cart );
|
||||||
}
|
}
|
||||||
SGSphered d;
|
SGSphered d;
|
||||||
for ( i = 0; i < wgs84_nodes.size(); ++i ) {
|
for ( i = 0; i < (int)wgs84_nodes.size(); ++i ) {
|
||||||
d.expandBy(wgs84_nodes[ i ]);
|
d.expandBy(wgs84_nodes[ i ]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1306,13 +1306,13 @@ void build_airport( string airport_id, float alt_m,
|
||||||
string name = airport_id + ".btg";
|
string name = airport_id + ".btg";
|
||||||
|
|
||||||
std::vector< SGVec3f > normals_3f;
|
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];
|
Point3D node = normals.get_node_list()[i];
|
||||||
normals_3f.push_back( node.toSGVec3f() );
|
normals_3f.push_back( node.toSGVec3f() );
|
||||||
}
|
}
|
||||||
|
|
||||||
std::vector< SGVec2f > texcoords_2f;
|
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];
|
Point3D node = texcoords.get_node_list()[i];
|
||||||
texcoords_2f.push_back( node.toSGVec2f() );
|
texcoords_2f.push_back( node.toSGVec2f() );
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,7 +69,7 @@ getIntersection (const Point3D &p0, const Point3D &p1,
|
||||||
void
|
void
|
||||||
makePolygon (const Point3D &p, double width, TGPolygon &polygon)
|
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 lon = p.x();
|
||||||
double lat = p.y();
|
double lat = p.y();
|
||||||
|
|
||||||
|
@ -101,7 +101,12 @@ makePolygon (const Line &line, double width, TGPolygon &polygon)
|
||||||
const Point3D p1 = line.getPoint(i);
|
const Point3D p1 = line.getPoint(i);
|
||||||
const Point3D p2 = line.getPoint(i+1);
|
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);
|
geo_inverse_wgs_84(0, p1.y(), p1.x(), p2.y(), p2.x(), &angle1, &angle2, &dist);
|
||||||
polygon.erase();
|
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_inner = Point3D(0.0f, 0.0f, 0.0f);
|
||||||
Point3D prev_outer = Point3D(0.0f, 0.0f, 0.0f);
|
Point3D prev_outer = Point3D(0.0f, 0.0f, 0.0f);
|
||||||
|
|
||||||
double last_end_v;
|
double last_end_v = 0.0f;
|
||||||
double heading, az2, dist;
|
double heading = 0.0f;
|
||||||
double pt_x, pt_y;
|
double az2 = 0.0f;
|
||||||
|
double dist = 0.0f;
|
||||||
|
double pt_x = 0.0f;
|
||||||
|
double pt_y = 0.0f;
|
||||||
|
|
||||||
TGPolygon poly;
|
TGPolygon poly;
|
||||||
TGTexParams tp;
|
TGTexParams tp;
|
||||||
|
|
|
@ -415,6 +415,8 @@ double Area(const Polygon &poly)
|
||||||
case rtHi:
|
case rtHi:
|
||||||
UseFullInt64Range = true;
|
UseFullInt64Range = true;
|
||||||
break;
|
break;
|
||||||
|
case rtLo:
|
||||||
|
break;
|
||||||
case rtError:
|
case rtError:
|
||||||
throw "Coordinate exceeds range bounds.";
|
throw "Coordinate exceeds range bounds.";
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ strAppend (string &s, int i)
|
||||||
s += buf;
|
s += buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if 0 /* UNUSED */
|
||||||
/**
|
/**
|
||||||
* Append a double-precision real to a string.
|
* Append a double-precision real to a string.
|
||||||
*/
|
*/
|
||||||
|
@ -48,7 +48,7 @@ strAppend (string &s, double f)
|
||||||
sprintf(buf, "%f", f);
|
sprintf(buf, "%f", f);
|
||||||
s += buf;
|
s += buf;
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Skip newlines.
|
* Skip newlines.
|
||||||
|
@ -141,7 +141,6 @@ checkZeros (istream &input)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check that the expected integer appears, or throw an exception.
|
* 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.
|
* 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());
|
throw E00Exception(message.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check that the expected string appears, or throw an exception.
|
* Check that the expected string appears, or throw an exception.
|
||||||
|
@ -541,8 +540,6 @@ E00::readIFO ()
|
||||||
{
|
{
|
||||||
int line_pos = 0;
|
int line_pos = 0;
|
||||||
string line = "";
|
string line = "";
|
||||||
int intval;
|
|
||||||
double realval;
|
|
||||||
|
|
||||||
checkPrecision(*_input);
|
checkPrecision(*_input);
|
||||||
|
|
||||||
|
@ -689,7 +686,7 @@ E00::postProcess ()
|
||||||
const E00::IFO *
|
const E00::IFO *
|
||||||
E00::getIFO (const string &fileName) const
|
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)
|
if (ifo_section[i].fileName == fileName)
|
||||||
return &(ifo_section[i]);
|
return &(ifo_section[i]);
|
||||||
}
|
}
|
||||||
|
@ -705,7 +702,7 @@ E00::getIFOItem (const string &fileName, int entry,
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int pos = -1;
|
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)
|
if (ifo->defs[i].itemName == itemName)
|
||||||
pos = i;
|
pos = i;
|
||||||
}
|
}
|
||||||
|
@ -723,8 +720,8 @@ E00::getIFOItemType (const string &fileName, const string &itemName) const
|
||||||
if (ifo == 0)
|
if (ifo == 0)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
int pos = -1;
|
// 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)
|
if (ifo->defs[i].itemName == itemName)
|
||||||
return &(ifo->defs[i].itemType);
|
return &(ifo->defs[i].itemType);
|
||||||
}
|
}
|
||||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -289,7 +289,7 @@ static int traverse_polygon(mcur, trnum, from, dir)
|
||||||
trap_t *t = &tr[trnum];
|
trap_t *t = &tr[trnum];
|
||||||
int mnew;
|
int mnew;
|
||||||
int v0, v1;
|
int v0, v1;
|
||||||
int retval;
|
int retval = 0;
|
||||||
int do_switch = FALSE;
|
int do_switch = FALSE;
|
||||||
|
|
||||||
if ((trnum <= 0) || visited[trnum])
|
if ((trnum <= 0) || visited[trnum])
|
||||||
|
|
|
@ -57,9 +57,11 @@
|
||||||
static char rcsid[] =
|
static char rcsid[] =
|
||||||
"$Id: dbfadd.c,v 1.7 2002/01/15 14:36:07 warmerda Exp $";
|
"$Id: dbfadd.c,v 1.7 2002/01/15 14:36:07 warmerda Exp $";
|
||||||
|
|
||||||
#include "shapefil.h"
|
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
#include "shapefil.h"
|
||||||
|
|
||||||
int main( int argc, char ** argv )
|
int main( int argc, char ** argv )
|
||||||
|
|
||||||
|
|
|
@ -76,8 +76,10 @@
|
||||||
* Initial revision
|
* Initial revision
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
#if 0
|
||||||
static char rcsid[] =
|
static char rcsid[] =
|
||||||
"$Id: shputils.c,v 1.7 2003/02/25 17:20:22 warmerda Exp $";
|
"$Id: shputils.c,v 1.7 2003/02/25 17:20:22 warmerda Exp $";
|
||||||
|
#endif
|
||||||
|
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include "shapefil.h"
|
#include "shapefil.h"
|
||||||
|
@ -121,6 +123,8 @@ void setext(char *pt, char *ext);
|
||||||
int strncasecmp2(char *s1, char *s2, int n);
|
int strncasecmp2(char *s1, char *s2, int n);
|
||||||
void mergefields(void);
|
void mergefields(void);
|
||||||
void findselect(void);
|
void findselect(void);
|
||||||
|
int findunit(char *unit);
|
||||||
|
|
||||||
void showitems(void);
|
void showitems(void);
|
||||||
int selectrec();
|
int selectrec();
|
||||||
int check_theme_bnd();
|
int check_theme_bnd();
|
||||||
|
@ -394,6 +398,9 @@ int main( int argc, char ** argv )
|
||||||
DBFWriteDoubleAttribute(hDBFappend, jRecord, pt[i],
|
DBFWriteDoubleAttribute(hDBFappend, jRecord, pt[i],
|
||||||
(DBFReadDoubleAttribute( hDBF, iRecord, i )) );
|
(DBFReadDoubleAttribute( hDBF, iRecord, i )) );
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -686,8 +693,8 @@ char *pt;
|
||||||
isum = isum + itmp;
|
isum = isum + itmp;
|
||||||
}
|
}
|
||||||
mean=isum/maxrec;
|
mean=isum/maxrec;
|
||||||
if (ilow < ihigh) printf("%d to %d \t(%.1f)",ilow,ihigh,mean);
|
if (ilow < ihigh) printf("%ld to %ld \t(%.1f)",ilow,ihigh,mean);
|
||||||
else if (ilow == ihigh) printf("= %d",ilow);
|
else if (ilow == ihigh) printf("= %ld",ilow);
|
||||||
else printf("No Values");
|
else printf("No Values");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -712,6 +719,8 @@ char *pt;
|
||||||
else printf("No Values");
|
else printf("No Values");
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -720,161 +729,207 @@ char *pt;
|
||||||
|
|
||||||
int selectrec()
|
int selectrec()
|
||||||
{
|
{
|
||||||
long int value, ty;
|
long int value, ty;
|
||||||
|
|
||||||
ty = DBFGetFieldInfo( hDBF, iselectitem, NULL, &iWidth, &iDecimals);
|
ty = DBFGetFieldInfo( hDBF, iselectitem, NULL, &iWidth, &iDecimals);
|
||||||
switch(ty)
|
switch(ty) {
|
||||||
{
|
case FTString:
|
||||||
case FTString:
|
puts("Invalid Item");
|
||||||
puts("Invalid Item");
|
iselect=FALSE;
|
||||||
iselect=FALSE;
|
break;
|
||||||
break;
|
|
||||||
case FTInteger:
|
case FTInteger:
|
||||||
value = DBFReadIntegerAttribute( hDBF, iRecord, iselectitem );
|
value = DBFReadIntegerAttribute( hDBF, iRecord, iselectitem );
|
||||||
for (j = 0; j<selcount; j++)
|
for (j = 0; j<selcount; j++) {
|
||||||
{
|
if (selectvalues[j] == value) {
|
||||||
if (selectvalues[j] == value)
|
if (iunselect) {
|
||||||
if (iunselect) return(0); /* Keep this record */
|
return(0); /* Keep this record */
|
||||||
else return(1); /* Skip this record */
|
} else {
|
||||||
}
|
return(1); /* Skip this record */
|
||||||
break;
|
}
|
||||||
case FTDouble:
|
}
|
||||||
puts("Invalid Item");
|
}
|
||||||
iselect=FALSE;
|
break;
|
||||||
break;
|
|
||||||
}
|
case FTDouble:
|
||||||
if (iunselect) return(1); /* Skip this record */
|
puts("Invalid Item");
|
||||||
else return(0); /* Keep this record */
|
iselect=FALSE;
|
||||||
|
break;
|
||||||
|
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (iunselect) {
|
||||||
|
return(1); /* Skip this record */
|
||||||
|
} else {
|
||||||
|
return(0); /* Keep this record */
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
int check_theme_bnd()
|
int check_theme_bnd()
|
||||||
{
|
{
|
||||||
if ( (adfBoundsMin[0] >= cxmin) && (adfBoundsMax[0] <= cxmax) &&
|
if ( (adfBoundsMin[0] >= cxmin) && (adfBoundsMax[0] <= cxmax) &&
|
||||||
(adfBoundsMin[1] >= cymin) && (adfBoundsMax[1] <= cymax) )
|
(adfBoundsMin[1] >= cymin) && (adfBoundsMax[1] <= cymax) ) {
|
||||||
{ /** Theme is totally inside clip area **/
|
/** Theme is totally inside clip area **/
|
||||||
if (ierase) nEntities=0; /** SKIP THEME **/
|
if (ierase) {
|
||||||
else iclip=FALSE; /** WRITE THEME (Clip not needed) **/
|
nEntities=0; /** SKIP THEME **/
|
||||||
|
} else {
|
||||||
|
iclip=FALSE; /** WRITE THEME (Clip not needed) **/
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ( (adfBoundsMin[0] < cxmin) && (adfBoundsMax[0] < cxmin) ) ||
|
if ( ( (adfBoundsMin[0] < cxmin) && (adfBoundsMax[0] < cxmin) ) ||
|
||||||
( (adfBoundsMin[1] < cymin) && (adfBoundsMax[1] < cymin) ) ||
|
( (adfBoundsMin[1] < cymin) && (adfBoundsMax[1] < cymin) ) ||
|
||||||
( (adfBoundsMin[0] > cxmax) && (adfBoundsMax[0] > cxmax) ) ||
|
( (adfBoundsMin[0] > cxmax) && (adfBoundsMax[0] > cxmax) ) ||
|
||||||
( (adfBoundsMin[1] > cymax) && (adfBoundsMax[1] > cymax) ) )
|
( (adfBoundsMin[1] > cymax) && (adfBoundsMax[1] > cymax) ) ) {
|
||||||
{ /** Theme is totally outside clip area **/
|
/** Theme is totally outside clip area **/
|
||||||
if (ierase) iclip=FALSE; /** WRITE THEME (Clip not needed) **/
|
if (ierase) {
|
||||||
else nEntities=0; /** SKIP THEME **/
|
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 **/
|
puts("WARNING: Theme is outside the clip area."); /** SKIP THEME **/
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
clip_boundary()
|
int clip_boundary()
|
||||||
{
|
{
|
||||||
int inside;
|
int inside;
|
||||||
int prev_outside;
|
int prev_outside;
|
||||||
int i2;
|
int i2;
|
||||||
int j2;
|
int j2;
|
||||||
|
|
||||||
/*** FIRST check the boundary of the feature ***/
|
/*** FIRST check the boundary of the feature ***/
|
||||||
if ( ( (psCShape->dfXMin < cxmin) && (psCShape->dfXMax < cxmin) ) ||
|
if ( ( (psCShape->dfXMin < cxmin) && (psCShape->dfXMax < cxmin) ) ||
|
||||||
( (psCShape->dfYMin < cymin) && (psCShape->dfYMax < cymin) ) ||
|
( (psCShape->dfYMin < cymin) && (psCShape->dfYMax < cymin) ) ||
|
||||||
( (psCShape->dfXMin > cxmax) && (psCShape->dfXMax > cxmax) ) ||
|
( (psCShape->dfXMin > cxmax) && (psCShape->dfXMax > cxmax) ) ||
|
||||||
( (psCShape->dfYMin > cymax) && (psCShape->dfYMax > cymax) ) )
|
( (psCShape->dfYMin > cymax) && (psCShape->dfYMax > cymax) ) ) {
|
||||||
{ /** Feature is totally outside clip area **/
|
/** Feature is totally outside clip area **/
|
||||||
if (ierase) return(1); /** WRITE RECORD **/
|
if (ierase) {
|
||||||
else return(0); /** SKIP RECORD **/
|
return(1); /** WRITE RECORD **/
|
||||||
}
|
} else {
|
||||||
|
return(0); /** SKIP RECORD **/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if ( (psCShape->dfXMin >= cxmin) && (psCShape->dfXMax <= cxmax) &&
|
if ( (psCShape->dfXMin >= cxmin) && (psCShape->dfXMax <= cxmax) &&
|
||||||
(psCShape->dfYMin >= cymin) && (psCShape->dfYMax <= cymax) )
|
(psCShape->dfYMin >= cymin) && (psCShape->dfYMax <= cymax) ) {
|
||||||
{ /** Feature is totally inside clip area **/
|
/** Feature is totally inside clip area **/
|
||||||
if (ierase) return(0); /** SKIP RECORD **/
|
if (ierase) {
|
||||||
else return(1); /** WRITE RECORD **/
|
return(0); /** SKIP RECORD **/
|
||||||
}
|
} else {
|
||||||
|
return(1); /** WRITE RECORD **/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (iinside)
|
if (iinside) { /** INSIDE * Feature might touch the boundary or could be outside **/
|
||||||
{ /** INSIDE * Feature might touch the boundary or could be outside **/
|
if (ierase) {
|
||||||
if (ierase) return(1); /** WRITE RECORD **/
|
return(1); /** WRITE RECORD **/
|
||||||
else return(0); /** SKIP 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 ( (psCShape->dfXMin >= cxmin) && (psCShape->dfXMax <= cxmax) &&
|
if (itouch) {
|
||||||
( (psCShape->dfYMin <= cymin) || (psCShape->dfYMax >= cymax) ) )
|
/** TOUCH **/
|
||||||
{ /** Feature intersects the clip boundary only on the Y axis **/
|
if ( ( (psCShape->dfXMin <= cxmin) || (psCShape->dfXMax >= cxmax) ) &&
|
||||||
if (ierase) return(0); /** SKIP RECORD **/
|
(psCShape->dfYMin >= cymin) && (psCShape->dfYMax <= cymax) ) {
|
||||||
else return(1); /** WRITE RECORD **/
|
/** 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++ )
|
for( j2 = 0; j2 < psCShape->nVertices; j2++ ) {
|
||||||
{ /** At least one vertex must be inside the clip boundary **/
|
/** At least one vertex must be inside the clip boundary **/
|
||||||
if ( (psCShape->padfX[j2] >= cxmin && psCShape->padfX[j2] <= cxmax) ||
|
if ( (psCShape->padfX[j2] >= cxmin && psCShape->padfX[j2] <= cxmax) ||
|
||||||
(psCShape->padfY[j2] >= cymin && psCShape->padfY[j2] <= cymax) )
|
(psCShape->padfY[j2] >= cymin && psCShape->padfY[j2] <= cymax) ) {
|
||||||
if (ierase) return(0); /** SKIP RECORD **/
|
if (ierase) {
|
||||||
else return(1); /** WRITE RECORD **/
|
return(0); /** SKIP RECORD **/
|
||||||
}
|
} else {
|
||||||
|
return(1); /** WRITE RECORD **/
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** All vertices are outside the clip boundary **/
|
/** All vertices are outside the clip boundary **/
|
||||||
if (ierase) return(1); /** WRITE RECORD **/
|
if (ierase) {
|
||||||
else return(0); /** SKIP RECORD **/
|
return(1); /** WRITE RECORD **/
|
||||||
} /** End TOUCH **/
|
} else {
|
||||||
|
return(0); /** SKIP RECORD **/
|
||||||
|
}
|
||||||
|
} /** End TOUCH **/
|
||||||
|
|
||||||
if (icut)
|
if (icut) {
|
||||||
{ /** CUT **/
|
/** CUT **/
|
||||||
/*** Check each vertex in the feature with the Boundary and "CUT" ***/
|
/*** Check each vertex in the feature with the Boundary and "CUT" ***/
|
||||||
/*** THIS CODE WAS NOT COMPLETED! READ NOTE AT THE BOTTOM ***/
|
/*** THIS CODE WAS NOT COMPLETED! READ NOTE AT THE BOTTOM ***/
|
||||||
i2=0;
|
i2=0;
|
||||||
prev_outside=FALSE;
|
prev_outside=FALSE;
|
||||||
for( j2 = 0; j2 < psCShape->nVertices; j2++ )
|
for( j2 = 0; j2 < psCShape->nVertices; j2++ ) {
|
||||||
{
|
inside = psCShape->padfX[j2] >= cxmin && psCShape->padfX[j2] <= cxmax &&
|
||||||
inside = psCShape->padfX[j2] >= cxmin && psCShape->padfX[j2] <= cxmax &&
|
psCShape->padfY[j2] >= cymin && psCShape->padfY[j2] <= cymax ;
|
||||||
psCShape->padfY[j2] >= cymin && psCShape->padfY[j2] <= cymax ;
|
|
||||||
|
|
||||||
if (ierase) inside=(! inside);
|
if (ierase) {
|
||||||
if (inside)
|
inside=(! inside);
|
||||||
{
|
}
|
||||||
if (i2 != j2)
|
|
||||||
{
|
if (inside) {
|
||||||
if (prev_outside)
|
if (i2 != j2) {
|
||||||
{
|
if (prev_outside) {
|
||||||
/*** AddIntersection(i2); /*** Add intersection ***/
|
/*** Add intersection ***/
|
||||||
prev_outside=FALSE;
|
prev_outside=FALSE;
|
||||||
}
|
}
|
||||||
psCShape->padfX[i2]=psCShape->padfX[j2]; /** move vertex **/
|
psCShape->padfX[i2]=psCShape->padfX[j2]; /** move vertex **/
|
||||||
psCShape->padfY[i2]=psCShape->padfY[j2];
|
psCShape->padfY[i2]=psCShape->padfY[j2];
|
||||||
}
|
}
|
||||||
i2++;
|
i2++;
|
||||||
} else {
|
} else {
|
||||||
if ( (! prev_outside) && (j2 > 0) )
|
if ( (! prev_outside) && (j2 > 0) ) {
|
||||||
{
|
/*** Add intersection (Watch out for j2==i2-1) ***/
|
||||||
/*** AddIntersection(i2); /*** Add intersection (Watch out for j2==i2-1) ***/
|
/*** Also a polygon may overlap twice and will split into a several parts ***/
|
||||||
/*** Also a polygon may overlap twice and will split into a several parts ***/
|
prev_outside=TRUE;
|
||||||
prev_outside=TRUE;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
printf("Vertices:%d OUT:%d Number of Parts:%d\n",
|
printf("Vertices:%d OUT:%d Number of Parts:%d\n",
|
||||||
psCShape->nVertices,i2, psCShape->nParts );
|
psCShape->nVertices,i2, psCShape->nParts );
|
||||||
|
|
||||||
psCShape->nVertices = i2;
|
psCShape->nVertices = i2;
|
||||||
|
|
||||||
if (i2 < 2) return(0); /** SKIP RECORD **/
|
if (i2 < 2) {
|
||||||
/*** (WE ARE NOT CREATING INTERESECTIONS and some lines could be reduced to one point) **/
|
return(0); /** SKIP RECORD **/
|
||||||
|
}
|
||||||
|
|
||||||
if (i2 == 0) return(0); /** SKIP RECORD **/
|
/*** (WE ARE NOT CREATING INTERESECTIONS and some lines could be reduced to one point) **/
|
||||||
else return(1); /** WRITE RECORD **/
|
if (i2 == 0) {
|
||||||
} /** End CUT **/
|
return(0); /** SKIP RECORD **/
|
||||||
|
} else {
|
||||||
|
return(1); /** WRITE RECORD **/
|
||||||
|
}
|
||||||
|
} /** End CUT **/
|
||||||
|
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -909,31 +964,29 @@ int j,i;
|
||||||
return(0);
|
return(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
#define NKEYS (sizeof(unitkeytab) / sizeof(struct unitkey))
|
#define NKEYS (sizeof(unitkeytab) / sizeof(struct unitkey))
|
||||||
findunit(unit)
|
int findunit(char *unit)
|
||||||
char *unit;
|
{
|
||||||
{
|
|
||||||
struct unitkey {
|
struct unitkey {
|
||||||
char *name;
|
char *name;
|
||||||
double value;
|
double value;
|
||||||
} unitkeytab[] = {
|
} unitkeytab[] = {
|
||||||
"CM", 39.37,
|
{ "CM", 39.37 },
|
||||||
"CENTIMETER", 39.37,
|
{ "CENTIMETER", 39.37 },
|
||||||
"CENTIMETERS", 39.37, /** # of inches * 100 in unit **/
|
{ "CENTIMETERS", 39.37 }, /** # of inches * 100 in unit **/
|
||||||
"METER", 3937,
|
{ "METER", 3937 },
|
||||||
"METERS", 3937,
|
{ "METERS", 3937 },
|
||||||
"KM", 3937000,
|
{ "KM", 3937000 },
|
||||||
"KILOMETER", 3937000,
|
{ "KILOMETER", 3937000 },
|
||||||
"KILOMETERS", 3937000,
|
{ "KILOMETERS", 3937000 },
|
||||||
"INCH", 100,
|
{ "INCH", 100 },
|
||||||
"INCHES", 100,
|
{ "INCHES", 100 },
|
||||||
"FEET", 1200,
|
{ "FEET", 1200 },
|
||||||
"FOOT", 1200,
|
{ "FOOT", 1200 },
|
||||||
"YARD", 3600,
|
{ "YARD", 3600 },
|
||||||
"YARDS", 3600,
|
{ "YARDS", 3600 },
|
||||||
"MILE", 6336000,
|
{ "MILE", 6336000 },
|
||||||
"MILES", 6336000
|
{ "MILES", 6336000 }
|
||||||
};
|
};
|
||||||
|
|
||||||
double unitfactor=0;
|
double unitfactor=0;
|
||||||
|
|
|
@ -529,49 +529,57 @@ VpfTable::read_double (istream &input) const
|
||||||
short
|
short
|
||||||
VpfTable::make_short (char buf[2]) const
|
VpfTable::make_short (char buf[2]) const
|
||||||
{
|
{
|
||||||
if (_system_byte_order == _file_byte_order) {
|
if (_system_byte_order == _file_byte_order) {
|
||||||
return *((short *)buf);
|
return *((short *)buf);
|
||||||
} else {
|
} else {
|
||||||
char out[2];
|
char out[2];
|
||||||
swap2(buf, out);
|
short *out_short = (short *)out;
|
||||||
return *((short *)out);
|
|
||||||
}
|
swap2(buf, out);
|
||||||
|
return *out_short;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
int
|
int
|
||||||
VpfTable::make_int (char buf[4]) const
|
VpfTable::make_int (char buf[4]) const
|
||||||
{
|
{
|
||||||
if (_system_byte_order == _file_byte_order) {
|
if (_system_byte_order == _file_byte_order) {
|
||||||
return *((int *)buf);
|
return *((int *)buf);
|
||||||
} else {
|
} else {
|
||||||
char out[4];
|
char out[4];
|
||||||
swap4(buf, out);
|
int *int_out = (int *)out;
|
||||||
return *((int *)out);
|
|
||||||
}
|
swap4(buf, out);
|
||||||
|
return *int_out;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
float
|
float
|
||||||
VpfTable::make_float (char buf[4]) const
|
VpfTable::make_float (char buf[4]) const
|
||||||
{
|
{
|
||||||
if (_system_byte_order == _file_byte_order) {
|
if (_system_byte_order == _file_byte_order) {
|
||||||
return *((float *)buf);
|
return *((float *)buf);
|
||||||
} else {
|
} else {
|
||||||
char out[4];
|
char out[4];
|
||||||
swap4(buf, out);
|
float *float_out = (float *)out;
|
||||||
return *((float *)out);
|
|
||||||
}
|
swap4(buf, out);
|
||||||
|
return *float_out;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
double
|
double
|
||||||
VpfTable::make_double (char buf[8]) const
|
VpfTable::make_double (char buf[8]) const
|
||||||
{
|
{
|
||||||
if (_system_byte_order == _file_byte_order) {
|
if (_system_byte_order == _file_byte_order) {
|
||||||
return *((double *)buf);
|
return *((double *)buf);
|
||||||
} else {
|
} else {
|
||||||
char out[8];
|
char out[8];
|
||||||
swap8(buf, out);
|
double *double_out = (double *)out;
|
||||||
return *((double *)out);
|
|
||||||
}
|
swap8(buf, out);
|
||||||
|
return *double_out;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -485,37 +485,41 @@ VpfValue::convertType (char rawType)
|
||||||
ostream &
|
ostream &
|
||||||
operator<< (ostream &output, const VpfValue &value)
|
operator<< (ostream &output, const VpfValue &value)
|
||||||
{
|
{
|
||||||
switch (value.getType()) {
|
switch (value.getType()) {
|
||||||
case VpfValue::TEXT:
|
case VpfValue::TEXT:
|
||||||
output << value.getText();
|
output << value.getText();
|
||||||
break;
|
break;
|
||||||
case VpfValue::INT:
|
case VpfValue::INT:
|
||||||
output << value.getInt();
|
output << value.getInt();
|
||||||
break;
|
break;
|
||||||
case VpfValue::REAL:
|
case VpfValue::REAL:
|
||||||
output << value.getReal();
|
output << value.getReal();
|
||||||
break;
|
break;
|
||||||
case VpfValue::POINTS: {
|
case VpfValue::POINTS: {
|
||||||
int nPoints = value.getElementCount();
|
int nPoints = value.getElementCount();
|
||||||
for (int i = 0; i < nPoints; i++) {
|
for (int i = 0; i < nPoints; i++) {
|
||||||
if (i > 0)
|
if (i > 0) {
|
||||||
output << ',';
|
output << ',';
|
||||||
output << '{' << value.getPoint(i).x << ','
|
}
|
||||||
<< value.getPoint(i).y << ',' << value.getPoint(i).z << '}';
|
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
|
// end of value.cxx
|
||||||
|
|
|
@ -79,33 +79,32 @@ struct SimpleRasterTransformerInfo {
|
||||||
double col_step, row_step;
|
double col_step, row_step;
|
||||||
};
|
};
|
||||||
|
|
||||||
int SimpleRasterTransformer(void *pTransformerArg,
|
int SimpleRasterTransformer(void *pTransformerArg,
|
||||||
int bDstToSrc, int nPointCount,
|
int bDstToSrc, int nPointCount,
|
||||||
double *x, double *y, double *z, int *panSuccess )
|
double *x, double *y, double *z, int *panSuccess )
|
||||||
{
|
{
|
||||||
SimpleRasterTransformerInfo* info=(SimpleRasterTransformerInfo*)pTransformerArg;
|
SimpleRasterTransformerInfo* info = (SimpleRasterTransformerInfo*)pTransformerArg;
|
||||||
int success;
|
int success;
|
||||||
|
|
||||||
if (bDstToSrc) {
|
if (bDstToSrc) {
|
||||||
/* transform destination -> source */
|
/* transform destination -> source */
|
||||||
for (int i=0;i<nPointCount;i++) {
|
for (int i = 0; i < nPointCount; i++) {
|
||||||
x[i]=info->x0+info->col_step*x[i];
|
x[i] = info->x0 + info->col_step * x[i];
|
||||||
y[i]=info->y0+info->row_step*y[i];
|
y[i] = info->y0 + info->row_step * y[i];
|
||||||
}
|
}
|
||||||
|
|
||||||
success=info->pfnTransformer(info->pTransformerArg,
|
success = info->pfnTransformer(info->pTransformerArg,
|
||||||
bDstToSrc,nPointCount,
|
bDstToSrc, nPointCount,
|
||||||
x,y,z,panSuccess);
|
x, y, z, panSuccess);
|
||||||
} else {
|
} else {
|
||||||
success=info->pfnTransformer(info->pTransformerArg,
|
success = info->pfnTransformer(info->pTransformerArg,
|
||||||
bDstToSrc,nPointCount,
|
bDstToSrc, nPointCount,
|
||||||
x,y,z,panSuccess);
|
x, y, z, panSuccess);
|
||||||
for (int i=0;i<nPointCount;i++) {
|
for (int i = 0; i < nPointCount; i++) {
|
||||||
if (!panSuccess[i]) {
|
if (!panSuccess[i])
|
||||||
continue;
|
continue;
|
||||||
}
|
x[i] = (x[i] - info->x0) / info->col_step;
|
||||||
x[i]=(x[i]-info->x0)/info->col_step;
|
y[i] = (y[i] - info->y0) / info->row_step;
|
||||||
y[i]=(y[i]-info->y0)/info->row_step;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return success;
|
return success;
|
||||||
|
@ -113,178 +112,183 @@ int SimpleRasterTransformer(void *pTransformerArg,
|
||||||
|
|
||||||
class ImageInfo {
|
class ImageInfo {
|
||||||
public:
|
public:
|
||||||
ImageInfo(GDALDataset *dataset);
|
ImageInfo(GDALDataset *dataset);
|
||||||
|
|
||||||
void GetBounds(double &n, double &s, double &e, double &w) const {
|
void GetBounds(double &n, double &s, double &e, double &w) const
|
||||||
n=north;
|
{
|
||||||
s=south;
|
n = north;
|
||||||
e=east;
|
s = south;
|
||||||
w=west;
|
e = east;
|
||||||
}
|
w = west;
|
||||||
|
}
|
||||||
const char* GetDescription() const {
|
|
||||||
return dataset->GetDescription();
|
const char* GetDescription() const
|
||||||
}
|
{
|
||||||
|
return dataset->GetDescription();
|
||||||
void GetDataChunk(int *buffer,
|
}
|
||||||
double x, double y,
|
|
||||||
double colstep, double rowstep,
|
void GetDataChunk(int *buffer,
|
||||||
int w, int h,
|
double x, double y,
|
||||||
int srcband=1, int nodata=-32768);
|
double colstep, double rowstep,
|
||||||
|
int w, int h,
|
||||||
|
int srcband = 1, int nodata = -32768);
|
||||||
protected:
|
protected:
|
||||||
/* The dataset */
|
/* The dataset */
|
||||||
GDALDataset *dataset;
|
GDALDataset *dataset;
|
||||||
|
|
||||||
/* Source spatial reference system */
|
/* Source spatial reference system */
|
||||||
OGRSpatialReference srs;
|
OGRSpatialReference srs;
|
||||||
|
|
||||||
/* Coordinate transformation pixel -> geographic */
|
/* Coordinate transformation pixel -> geographic */
|
||||||
double geoXfrm[6];
|
double geoXfrm[6];
|
||||||
|
|
||||||
/* Coordinate transformation to WGS84 */
|
/* Coordinate transformation to WGS84 */
|
||||||
OGRCoordinateTransformation *wgs84xform;
|
OGRCoordinateTransformation *wgs84xform;
|
||||||
|
|
||||||
/* geographical edge coordinates in CCW order, WGS84 */
|
/* geographical edge coordinates in CCW order, WGS84 */
|
||||||
double geoX[4],geoY[4];
|
double geoX[4], geoY[4];
|
||||||
|
|
||||||
/* bounding box in WGS84 */
|
/* bounding box in WGS84 */
|
||||||
double north,south,east,west;
|
double north, south, east, west;
|
||||||
};
|
};
|
||||||
|
|
||||||
ImageInfo::ImageInfo(GDALDataset *dataset):
|
ImageInfo::ImageInfo(GDALDataset *dataset) :
|
||||||
dataset(dataset),
|
dataset(dataset),
|
||||||
srs(dataset->GetProjectionRef())
|
srs(dataset->GetProjectionRef())
|
||||||
{
|
{
|
||||||
OGRSpatialReference wgs84SRS;
|
OGRSpatialReference wgs84SRS;
|
||||||
|
|
||||||
wgs84SRS.SetWellKnownGeogCS( "EPSG:4326" );
|
wgs84SRS.SetWellKnownGeogCS( "EPSG:4326" );
|
||||||
|
|
||||||
|
|
||||||
/* Determine the bounds of the input file in WGS84 */
|
/* Determine the bounds of the input file in WGS84 */
|
||||||
int w=dataset->GetRasterXSize();
|
int w = dataset->GetRasterXSize();
|
||||||
int h=dataset->GetRasterYSize();
|
int h = dataset->GetRasterYSize();
|
||||||
|
|
||||||
if (dataset->GetGeoTransform(geoXfrm)!=CE_None) {
|
if (dataset->GetGeoTransform(geoXfrm) != CE_None) {
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT,
|
SG_LOG(SG_GENERAL, SG_ALERT,
|
||||||
"Could not determine transform matrix for dataset "
|
"Could not determine transform matrix for dataset "
|
||||||
"'" << dataset->GetDescription() << "'"
|
"'" << dataset->GetDescription() << "'"
|
||||||
":" << CPLGetLastErrorMsg());
|
":" << CPLGetLastErrorMsg());
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/* create points in CCW order */
|
/* create points in CCW order */
|
||||||
geoX[0]=geoXfrm[0]+0*geoXfrm[1]+0*geoXfrm[2];
|
geoX[0] = geoXfrm[0] + 0 * geoXfrm[1] + 0 * geoXfrm[2];
|
||||||
geoX[1]=geoXfrm[0]+0*geoXfrm[1]+h*geoXfrm[2];
|
geoX[1] = geoXfrm[0] + 0 * geoXfrm[1] + h * geoXfrm[2];
|
||||||
geoX[2]=geoXfrm[0]+w*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];
|
geoX[3] = geoXfrm[0] + w * geoXfrm[1] + 0 * geoXfrm[2];
|
||||||
geoY[0]=geoXfrm[3]+0*geoXfrm[4]+0*geoXfrm[5];
|
geoY[0] = geoXfrm[3] + 0 * geoXfrm[4] + 0 * geoXfrm[5];
|
||||||
geoY[1]=geoXfrm[3]+0*geoXfrm[4]+h*geoXfrm[5];
|
geoY[1] = geoXfrm[3] + 0 * geoXfrm[4] + h * geoXfrm[5];
|
||||||
geoY[2]=geoXfrm[3]+w*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];
|
geoY[3] = geoXfrm[3] + w * geoXfrm[4] + 0 * geoXfrm[5];
|
||||||
|
|
||||||
const char* projRef=dataset->GetProjectionRef();
|
const char* projRef = dataset->GetProjectionRef();
|
||||||
|
|
||||||
srs=OGRSpatialReference(projRef);
|
srs = OGRSpatialReference(projRef);
|
||||||
|
|
||||||
wgs84xform = OGRCreateCoordinateTransformation( &srs, &wgs84SRS );
|
wgs84xform = OGRCreateCoordinateTransformation( &srs, &wgs84SRS );
|
||||||
|
|
||||||
if (!wgs84xform->Transform(4,geoX,geoY)) {
|
if (!wgs84xform->Transform(4, geoX, geoY)) {
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT,
|
SG_LOG(SG_GENERAL, SG_ALERT,
|
||||||
"Could not transform edge points of dataset "
|
"Could not transform edge points of dataset "
|
||||||
"'" << dataset->GetDescription() << "'"
|
"'" << dataset->GetDescription() << "'"
|
||||||
":" << CPLGetLastErrorMsg());
|
":" << CPLGetLastErrorMsg());
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
east=west=geoX[0];
|
east = west = geoX[0];
|
||||||
north=south=geoY[0];
|
north = south = geoY[0];
|
||||||
|
|
||||||
for (int j=1;j<4;j++) {
|
for (int j = 1; j < 4; j++) {
|
||||||
north=std::max(north,geoY[j]);
|
north = std::max(north, geoY[j]);
|
||||||
south=std::min(south,geoY[j]);
|
south = std::min(south, geoY[j]);
|
||||||
east =std::max(east ,geoX[j]);
|
east = std::max(east, geoX[j]);
|
||||||
west =std::min(west ,geoX[j]);
|
west = std::min(west, geoX[j]);
|
||||||
}
|
}
|
||||||
|
|
||||||
SG_LOG(SG_GENERAL, SG_INFO,
|
SG_LOG(SG_GENERAL, SG_INFO,
|
||||||
"INFO: Bounds for '" << dataset->GetDescription() << "' are"
|
"INFO: Bounds for '" << dataset->GetDescription() << "' are"
|
||||||
" n=" << north << " s=" << south <<
|
" n=" << north << " s=" << south <<
|
||||||
" e=" << east << " w=" << west);
|
" e=" << east << " w=" << west);
|
||||||
}
|
}
|
||||||
|
|
||||||
void ImageInfo::GetDataChunk(int *buffer,
|
void ImageInfo::GetDataChunk(int *buffer,
|
||||||
double x, double y,
|
double x, double y,
|
||||||
double colstep, double rowstep,
|
double colstep, double rowstep,
|
||||||
int w, int h,
|
int w, int h,
|
||||||
int srcband, int nodata) {
|
int srcband, int nodata)
|
||||||
|
{
|
||||||
OGRSpatialReference wgs84SRS;
|
OGRSpatialReference wgs84SRS;
|
||||||
|
|
||||||
wgs84SRS.SetWellKnownGeogCS( "EPSG:4326" );
|
wgs84SRS.SetWellKnownGeogCS( "EPSG:4326" );
|
||||||
|
|
||||||
char* wgs84WKT;
|
char* wgs84WKT;
|
||||||
|
|
||||||
wgs84SRS.exportToWkt(&wgs84WKT);
|
wgs84SRS.exportToWkt(&wgs84WKT);
|
||||||
|
|
||||||
/* Setup a raster transformation from WGS84 to raster coordinates of the array files */
|
/* Setup a raster transformation from WGS84 to raster coordinates of the array files */
|
||||||
SimpleRasterTransformerInfo xformData;
|
SimpleRasterTransformerInfo xformData;
|
||||||
xformData.pTransformerArg=GDALCreateGenImgProjTransformer(
|
xformData.pTransformerArg = GDALCreateGenImgProjTransformer(
|
||||||
dataset,NULL,
|
dataset, NULL,
|
||||||
NULL,wgs84WKT,
|
NULL, wgs84WKT,
|
||||||
FALSE,
|
FALSE,
|
||||||
0.0,
|
0.0,
|
||||||
1);
|
1);
|
||||||
xformData.pfnTransformer=GDALGenImgProjTransform;
|
xformData.pfnTransformer = GDALGenImgProjTransform;
|
||||||
xformData.x0=x;
|
xformData.x0 = x;
|
||||||
xformData.y0=y;
|
xformData.y0 = y;
|
||||||
xformData.col_step=colstep;
|
xformData.col_step = colstep;
|
||||||
xformData.row_step=rowstep;
|
xformData.row_step = rowstep;
|
||||||
|
|
||||||
// TODO: check if this image can actually cover part of the chunk
|
// TODO: check if this image can actually cover part of the chunk
|
||||||
|
|
||||||
/* establish the full source to target transformation */
|
/* establish the full source to target transformation */
|
||||||
GDALWarpOptions *psWarpOptions = GDALCreateWarpOptions();
|
GDALWarpOptions *psWarpOptions = GDALCreateWarpOptions();
|
||||||
|
|
||||||
int srcBandNumbers[]={srcband};
|
int srcBandNumbers[] = { srcband };
|
||||||
int dstBandNumbers[]={1};
|
int dstBandNumbers[] = { 1 };
|
||||||
double dstNodata[]={nodata};
|
double dstNodata[] = { nodata };
|
||||||
double srcNodataReal[1];
|
double srcNodataReal[1];
|
||||||
double srcNodataImag[]={0.0};
|
double srcNodataImag[] = { 0.0 };
|
||||||
int srcHasNodataValue;
|
int srcHasNodataValue;
|
||||||
|
|
||||||
srcNodataReal[0]=dataset->GetRasterBand(srcband)->GetNoDataValue(&srcHasNodataValue);
|
srcNodataReal[0] = dataset->GetRasterBand(srcband)->GetNoDataValue(&srcHasNodataValue);
|
||||||
|
|
||||||
psWarpOptions->hSrcDS=dataset;
|
psWarpOptions->hSrcDS = dataset;
|
||||||
psWarpOptions->hDstDS=NULL;
|
psWarpOptions->hDstDS = NULL;
|
||||||
psWarpOptions->nBandCount=1;
|
psWarpOptions->nBandCount = 1;
|
||||||
psWarpOptions->panSrcBands=srcBandNumbers;
|
psWarpOptions->panSrcBands = srcBandNumbers;
|
||||||
psWarpOptions->panDstBands=dstBandNumbers;
|
psWarpOptions->panDstBands = dstBandNumbers;
|
||||||
psWarpOptions->nSrcAlphaBand=0;
|
psWarpOptions->nSrcAlphaBand = 0;
|
||||||
psWarpOptions->nDstAlphaBand=0;
|
psWarpOptions->nDstAlphaBand = 0;
|
||||||
psWarpOptions->padfSrcNoDataReal=(srcHasNodataValue?srcNodataReal:NULL);
|
psWarpOptions->padfSrcNoDataReal = (srcHasNodataValue ? srcNodataReal : NULL);
|
||||||
psWarpOptions->padfSrcNoDataImag=(srcHasNodataValue?srcNodataImag:NULL);
|
psWarpOptions->padfSrcNoDataImag = (srcHasNodataValue ? srcNodataImag : NULL);
|
||||||
psWarpOptions->padfDstNoDataReal=dstNodata;
|
psWarpOptions->padfDstNoDataReal = dstNodata;
|
||||||
psWarpOptions->eResampleAlg = GRA_Bilinear;
|
psWarpOptions->eResampleAlg = GRA_Bilinear;
|
||||||
psWarpOptions->eWorkingDataType = GDT_Int32;
|
psWarpOptions->eWorkingDataType = GDT_Int32;
|
||||||
|
|
||||||
psWarpOptions->pfnTransformer=SimpleRasterTransformer;
|
psWarpOptions->pfnTransformer = SimpleRasterTransformer;
|
||||||
psWarpOptions->pTransformerArg=&xformData;
|
psWarpOptions->pTransformerArg = &xformData;
|
||||||
|
|
||||||
GDALWarpOperation oOperation;
|
GDALWarpOperation oOperation;
|
||||||
|
|
||||||
oOperation.Initialize( psWarpOptions );
|
oOperation.Initialize( psWarpOptions );
|
||||||
|
|
||||||
/* do the warp */
|
/* 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,
|
SG_LOG(SG_GENERAL, SG_ALERT,
|
||||||
"Could not warp to buffer on dataset '" << GetDescription() << "'"
|
"Could not warp to buffer on dataset '" << GetDescription() << "'"
|
||||||
":" << CPLGetLastErrorMsg());
|
":" << CPLGetLastErrorMsg());
|
||||||
}
|
}
|
||||||
|
|
||||||
/* clean up */
|
/* clean up */
|
||||||
psWarpOptions->panSrcBands=NULL;
|
psWarpOptions->panSrcBands = NULL;
|
||||||
psWarpOptions->panDstBands=NULL;
|
psWarpOptions->panDstBands = NULL;
|
||||||
psWarpOptions->padfSrcNoDataReal=NULL;
|
psWarpOptions->padfSrcNoDataReal = NULL;
|
||||||
psWarpOptions->padfSrcNoDataImag=NULL;
|
psWarpOptions->padfSrcNoDataImag = NULL;
|
||||||
psWarpOptions->padfDstNoDataReal=NULL;
|
psWarpOptions->padfDstNoDataReal = NULL;
|
||||||
|
|
||||||
GDALDestroyGenImgProjTransformer( xformData.pTransformerArg );
|
GDALDestroyGenImgProjTransformer( xformData.pTransformerArg );
|
||||||
GDALDestroyWarpOptions( psWarpOptions );
|
GDALDestroyWarpOptions( psWarpOptions );
|
||||||
}
|
}
|
||||||
|
@ -294,117 +298,117 @@ void write_bucket(const string& work_dir, SGBucket bucket,
|
||||||
int min_x, int min_y,
|
int min_x, int min_y,
|
||||||
int span_x, int span_y,
|
int span_x, int span_y,
|
||||||
int col_step, int row_step,
|
int col_step, int row_step,
|
||||||
bool compress=true) {
|
bool compress = true)
|
||||||
SGPath path(work_dir);
|
{
|
||||||
path.append(bucket.gen_base_path());
|
SGPath path(work_dir);
|
||||||
path.create_dir( 0755 );
|
|
||||||
|
|
||||||
string array_file = path.str() + "/" + bucket.gen_index_str() + ".arr";
|
path.append(bucket.gen_base_path());
|
||||||
|
path.create_dir( 0755 );
|
||||||
FILE *fp;
|
|
||||||
if ( (fp = fopen(array_file.c_str(), "w")) == NULL ) {
|
string array_file = path.str() + "/" + bucket.gen_index_str() + ".arr";
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT, "cannot open " << array_file << " for writing!");
|
|
||||||
exit(-1);
|
FILE *fp;
|
||||||
}
|
if ( (fp = fopen(array_file.c_str(), "w")) == NULL ) {
|
||||||
|
SG_LOG(SG_GENERAL, SG_ALERT, "cannot open " << array_file << " for writing!");
|
||||||
fprintf( fp, "%d %d\n", min_x, min_y );
|
exit(-1);
|
||||||
fprintf( fp, "%d %d %d %d\n",
|
}
|
||||||
span_x + 1, col_step,
|
|
||||||
span_y + 1, row_step );
|
fprintf( fp, "%d %d\n", min_x, min_y );
|
||||||
int k=0;
|
fprintf( fp, "%d %d %d %d\n",
|
||||||
for ( int x = 0; x <= span_x; ++x ) {
|
span_x + 1, col_step,
|
||||||
for ( int y = 0; y <= span_y; ++y ) {
|
span_y + 1, row_step );
|
||||||
fprintf( fp, "%d ", buffer[ y * span_x + x ] );
|
|
||||||
}
|
for ( int x = 0; x <= span_x; ++x ) {
|
||||||
fprintf( fp, "\n" );
|
for ( int y = 0; y <= span_y; ++y )
|
||||||
}
|
fprintf( fp, "%d ", buffer[ y * span_x + x ] );
|
||||||
fclose(fp);
|
fprintf( fp, "\n" );
|
||||||
|
}
|
||||||
if ( compress ) {
|
fclose(fp);
|
||||||
string command = "gzip --best -f " + array_file;
|
|
||||||
system( command.c_str() );
|
if ( compress ) {
|
||||||
}
|
string command = "gzip --best -f " + array_file;
|
||||||
|
system( command.c_str() );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void process_bucket(const string& work_dir, SGBucket bucket,
|
void process_bucket(const string& work_dir, SGBucket bucket,
|
||||||
ImageInfo* images[], int imagecount,
|
ImageInfo* images[], int imagecount,
|
||||||
bool forceWrite=false) {
|
bool forceWrite = false)
|
||||||
double clat,clon;
|
{
|
||||||
double bnorth,bsouth,beast,bwest;
|
double clat, clon;
|
||||||
|
double bnorth, bsouth, beast, bwest;
|
||||||
clat=bucket.get_center_lat();
|
|
||||||
clon=bucket.get_center_lon();
|
clat = bucket.get_center_lat();
|
||||||
|
clon = bucket.get_center_lon();
|
||||||
bnorth=clat+bucket.get_height()/2.0;
|
|
||||||
bsouth=clat-bucket.get_height()/2.0;
|
bnorth = clat + bucket.get_height() / 2.0;
|
||||||
beast =clon+bucket.get_width()/2.0;
|
bsouth = clat - bucket.get_height() / 2.0;
|
||||||
bwest =clon-bucket.get_width()/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);
|
|
||||||
|
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;
|
/* 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);
|
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;
|
// TODO: Make other resolutions possible as well
|
||||||
span_x=bucket.get_width()*3600/col_step;
|
int col_step = 3, row_step = 3;
|
||||||
span_y=bucket.get_height()*3600/row_step;
|
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]);
|
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));
|
|
||||||
|
::memset(buffer.get(), -1, (span_x + 1) * (span_y + 1) * sizeof(int));
|
||||||
for (int i=0;i<imagecount;i++) {
|
|
||||||
double inorth,isouth,ieast,iwest;
|
for (int i = 0; i < imagecount; i++) {
|
||||||
images[i]->GetBounds(inorth,isouth,ieast,iwest);
|
double inorth, isouth, ieast, iwest;
|
||||||
|
images[i]->GetBounds(inorth, isouth, ieast, iwest);
|
||||||
images[i]->GetDataChunk(buffer.get(),
|
|
||||||
bwest, bsouth,
|
images[i]->GetDataChunk(buffer.get(),
|
||||||
col_step/3600.0, row_step/3600.0,
|
bwest, bsouth,
|
||||||
span_x+1, span_y+1);
|
col_step / 3600.0, row_step / 3600.0,
|
||||||
}
|
span_x + 1, span_y + 1);
|
||||||
|
}
|
||||||
/* ...check the amount of undefined cells... */
|
|
||||||
int nodataCellCount=0;
|
/* ...check the amount of undefined cells... */
|
||||||
|
int nodataCellCount = 0;
|
||||||
for (int i=0;i<cellcount;i++) {
|
|
||||||
if (buffer[i]==-32768) {
|
for (int i = 0; i < cellcount; i++)
|
||||||
nodataCellCount++;
|
if (buffer[i] == -32768)
|
||||||
}
|
nodataCellCount++;
|
||||||
}
|
|
||||||
|
const double nodataPercLimit = 5.0;
|
||||||
const double nodataPercLimit=5.0;
|
double nodataPerc = 100.0 * nodataCellCount / cellcount;
|
||||||
double nodataPerc=100.0*nodataCellCount/cellcount;
|
|
||||||
|
if (nodataCellCount > 0)
|
||||||
if (nodataCellCount>0) {
|
SG_LOG(SG_GENERAL, SG_INFO, " " << nodataCellCount << " cells are not covered with data (" << nodataPerc << "% of cells)");
|
||||||
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 << "%)");
|
||||||
if (nodataPerc>nodataPercLimit) {
|
/* don't write out if not forced to */
|
||||||
SG_LOG(SG_GENERAL, SG_INFO, " there is not enough data available to cover this cell (limit for non-covered cells is " << nodataPercLimit <<"%)");
|
if (!forceWrite)
|
||||||
/* don't write out if not forced to */
|
return;
|
||||||
if (!forceWrite)
|
}
|
||||||
return;
|
|
||||||
}
|
/* ...and write it out */
|
||||||
|
write_bucket(work_dir, bucket,
|
||||||
/* ...and write it out */
|
buffer.get(),
|
||||||
write_bucket(work_dir, bucket,
|
min_x, min_y,
|
||||||
buffer.get(),
|
span_x, span_y,
|
||||||
min_x, min_y,
|
col_step, row_step);
|
||||||
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 );
|
sglog().setLogLevels( SG_ALL, SG_INFO );
|
||||||
|
|
||||||
if ( argc < 3 ) {
|
if ( argc < 3 ) {
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT,
|
SG_LOG(SG_GENERAL, SG_ALERT,
|
||||||
"Usage " << argv[0] << " <work_dir> <datasetname...> [-- <bucket-idx> ...]");
|
"Usage " << argv[0] << " <work_dir> <datasetname...> [-- <bucket-idx> ...]");
|
||||||
exit(-1);
|
exit(-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
SGPath work_dir( argv[1] );
|
SGPath work_dir( argv[1] );
|
||||||
|
@ -413,61 +417,59 @@ int main(int argc, const char **argv) {
|
||||||
|
|
||||||
GDALAllRegister();
|
GDALAllRegister();
|
||||||
|
|
||||||
int datasetcount=0,tilecount=0;
|
int datasetcount = 0, tilecount = 0;
|
||||||
int dashpos;
|
int dashpos;
|
||||||
|
|
||||||
for (dashpos=2;dashpos<argc;dashpos++) {
|
for (dashpos = 2; dashpos < argc; dashpos++)
|
||||||
if (!strcmp(argv[dashpos],"--")) {
|
if (!strcmp(argv[dashpos], "--"))
|
||||||
break;
|
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;
|
const char** tilenames = argv + dashpos + 1;
|
||||||
tilecount=(dashpos==argc?0:argc-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] );
|
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
|
// TODO: allow specification of bounds by user
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Step 1: Open all provided datasets and determine their bounds in WGS84.
|
* Step 1: Open all provided datasets and determine their bounds in WGS84.
|
||||||
*/
|
*/
|
||||||
for (int i=0;i<datasetcount;i++) {
|
for (int i = 0; i < datasetcount; i++) {
|
||||||
GDALDataset* dataset;
|
GDALDataset* dataset;
|
||||||
|
|
||||||
dataset=(GDALDataset *)GDALOpenShared(datasetnames[i],GA_ReadOnly);
|
dataset = (GDALDataset*)GDALOpenShared(datasetnames[i], GA_ReadOnly);
|
||||||
|
|
||||||
if (dataset==NULL) {
|
if (dataset == NULL) {
|
||||||
SG_LOG(SG_GENERAL, SG_ALERT,
|
SG_LOG(SG_GENERAL, SG_ALERT,
|
||||||
"Could not open dataset '" << datasetnames[i] << "'"
|
"Could not open dataset '" << datasetnames[i] << "'"
|
||||||
":" << CPLGetLastErrorMsg());
|
":" << CPLGetLastErrorMsg());
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
images[i]=new ImageInfo(dataset);
|
images[i] = new ImageInfo(dataset);
|
||||||
|
|
||||||
double inorth,isouth,ieast,iwest;
|
double inorth, isouth, ieast, iwest;
|
||||||
images[i]->GetBounds(inorth,isouth,ieast,iwest);
|
images[i]->GetBounds(inorth, isouth, ieast, iwest);
|
||||||
|
|
||||||
north=std::max(north,inorth);
|
north = std::max(north, inorth);
|
||||||
south=std::min(south,isouth);
|
south = std::min(south, isouth);
|
||||||
east =std::max(east ,ieast );
|
east = std::max(east, ieast );
|
||||||
west =std::min(west ,iwest );
|
west = std::min(west, iwest );
|
||||||
}
|
}
|
||||||
|
|
||||||
SG_LOG(SG_GENERAL, SG_INFO, "Complete bounds n=" << north << " s=" << south << " e=" << east << " w=" << west);
|
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
|
* Step 2: If no tiles were specified, go through all tiles contained in
|
||||||
* the common bounds of all datasets and find those which have
|
* 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
|
* all of them. Warn if no sufficient coverage (non-null pixels) is
|
||||||
* available.
|
* available.
|
||||||
*/
|
*/
|
||||||
if (tilecount==0) {
|
if (tilecount == 0) {
|
||||||
/*
|
/*
|
||||||
* No tiles were specified, so we determine the common bounds of all
|
* No tiles were specified, so we determine the common bounds of all
|
||||||
* specified datasets and check all the tiles contained in them.
|
* specified datasets and check all the tiles contained in them.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
SGBucket start(west,south),end(east,north);
|
SGBucket start(west, south), end(east, north);
|
||||||
|
|
||||||
int dx,dy;
|
int dx, dy;
|
||||||
|
|
||||||
sgBucketDiff(start, end, &dx, &dy);
|
sgBucketDiff(start, end, &dx, &dy);
|
||||||
|
|
||||||
SG_LOG(SG_GENERAL, SG_INFO, "dx=" << dx << " dy=" << dy);
|
SG_LOG(SG_GENERAL, SG_INFO, "dx=" << dx << " dy=" << dy);
|
||||||
|
|
||||||
for (int x=0;x<=dx;x++) {
|
for (int x = 0; x <= dx; x++) {
|
||||||
for (int y=0;y<=dy;y++) {
|
for (int y = 0; y <= dy; y++) {
|
||||||
SGBucket bucket=sgBucketOffset(west,south,x,y);
|
SGBucket bucket = sgBucketOffset(west, south, x, y);
|
||||||
|
|
||||||
process_bucket(work_dir.str(),bucket,images.get(),datasetcount);
|
process_bucket(work_dir.str(), bucket, images.get(), datasetcount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -502,13 +504,13 @@ int main(int argc, const char **argv) {
|
||||||
* Tiles were specified, so process them and warn if not enough
|
* Tiles were specified, so process them and warn if not enough
|
||||||
* data is available, but write them in any case.
|
* 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]));
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,7 @@ static unsigned int timestamp = 0;
|
||||||
|
|
||||||
static void overEdge(Edge *e, edge_callback fn, void *closure)
|
static void overEdge(Edge *e, edge_callback fn, void *closure)
|
||||||
{
|
{
|
||||||
if( e->token != timestamp )
|
if( e->token != (int)timestamp )
|
||||||
{
|
{
|
||||||
e->token = timestamp;
|
e->token = timestamp;
|
||||||
e->Sym()->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 to = triArea(x, eo->Dest(), eo->Org());
|
||||||
real td = triArea(x, ed->Dest(), ed->Org());
|
real td = triArea(x, ed->Dest(), ed->Org());
|
||||||
|
|
||||||
if (td>0) // x is below ed
|
if ( td > 0 ) { // x is below ed
|
||||||
if (to>0 || to==0 && t==0) {// x is interior, or origin endpoint
|
if ( (to > 0) || (to==0 && t==0) ) { // x is interior, or origin endpoint
|
||||||
startingEdge = e;
|
startingEdge = e;
|
||||||
return e;
|
return e;
|
||||||
}
|
}
|
||||||
else { // x is below ed, below eo
|
else { // x is below ed, below eo
|
||||||
t = to;
|
t = to;
|
||||||
e = eo;
|
e = eo;
|
||||||
}
|
}
|
||||||
else // x is on or above ed
|
}
|
||||||
if (to>0) // x is above eo
|
else { // x is on or above ed
|
||||||
if (td==0 && t==0) { // x is destination endpoint
|
if (to>0) { // x is above eo
|
||||||
|
if (td==0 && t==0) { // x is destination endpoint
|
||||||
startingEdge = e;
|
startingEdge = e;
|
||||||
return 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;
|
t = td;
|
||||||
e = ed;
|
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
|
// x on e but subdiv. is to right
|
||||||
e = e->Sym();
|
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;
|
e = eo;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
t = td;
|
t = td;
|
||||||
e = ed;
|
e = ed;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -372,7 +377,7 @@ void Subdivision::optimize(Vec2& x, Edge *s)
|
||||||
do {
|
do {
|
||||||
|
|
||||||
Edge *e = spoke->Lnext();
|
Edge *e = spoke->Lnext();
|
||||||
Edge *t = e->Oprev();
|
// Edge *t = e->Oprev();
|
||||||
|
|
||||||
if( isInterior(e) && shouldSwap(x, e) )
|
if( isInterior(e) && shouldSwap(x, e) )
|
||||||
swap(e);
|
swap(e);
|
||||||
|
|
Loading…
Add table
Reference in a new issue