From 858191ead91355cf443cf2de4640796d84d163fa Mon Sep 17 00:00:00 2001 From: Christian Schmitt Date: Sun, 11 Nov 2012 11:35:47 +0100 Subject: [PATCH] Remove some warnings that MSVC complained about --- src/BuildTiles/Main/usgs.cxx | 10 +- src/BuildTiles/Main/usgs.hxx | 5 +- src/BuildTiles/Parallel/server.cxx | 28 +++--- src/Utils/poly2ogr/poly2ogr.cxx | 152 ++++++++++++++--------------- 4 files changed, 97 insertions(+), 98 deletions(-) diff --git a/src/BuildTiles/Main/usgs.cxx b/src/BuildTiles/Main/usgs.cxx index 78da9274..2c265ff0 100644 --- a/src/BuildTiles/Main/usgs.cxx +++ b/src/BuildTiles/Main/usgs.cxx @@ -36,13 +36,13 @@ static vector usgs_map; int load_usgs_map( const std::string& filename ) { ifstream in ( filename.c_str() ); - + if ( ! in ) { SG_LOG(SG_GENERAL, SG_ALERT, "Unable to open USGS map file " << filename); return 0; } SG_LOG(SG_GENERAL, SG_ALERT, "USGS Map file is " << filename); - + in >> skipcomment; while ( !in.eof() ) { string name; @@ -50,14 +50,14 @@ int load_usgs_map( const std::string& filename ) { usgs_map.push_back( get_area_type( name ) ); in >> skipcomment; } - + in.close(); - + return 1; } // Translate USGS land cover values into TerraGear area types. -AreaType translateUSGSCover (int usgs_value) +AreaType translateUSGSCover (unsigned int usgs_value) { if ( 0 --height=] " - << " chunk1 chunk2 ..." + << " chunk1 chunk2 ..." << endl; cout << "\twhere chunk represents the south west corner of the area" << endl; @@ -363,7 +363,7 @@ DWORD WINAPI ThreadProc(void* p) { DWORD pN1; - ULONG_PTR pN2; + ULONG_PTR pN2; OVERLAPPED* pOverLapped; while( GetQueuedCompletionStatus(gIoPort, &pN1, &pN2, &pOverLapped, INFINITE)) { @@ -386,7 +386,7 @@ ThreadProc(void* p) int main( int argc, char **argv ) { int arg_counter; long int next_tile; - int sock, msgsock, length, pid; + int sock, msgsock; fd_set ready; short unsigned int port; @@ -457,7 +457,7 @@ int main( int argc, char **argv ) { for ( ;; ) { FD_ZERO(&ready); FD_SET(sock, &ready); - + // block until we get some input on sock select(sock+1, &ready, 0, 0, NULL); @@ -476,9 +476,9 @@ int main( int argc, char **argv ) { } } - cout << "Bucket = " << SGBucket(next_tile) + cout << "Bucket = " << SGBucket(next_tile) << " (" << pass << ")" << endl; - + log_pending_tile( status_dir, next_tile ); // cout << "next tile = " << next_tile << endl;; @@ -487,7 +487,7 @@ int main( int argc, char **argv ) { #ifndef _MSC_VER // spawn a child - pid = fork(); + int pid = fork(); if ( pid < 0 ) { // error @@ -500,7 +500,7 @@ int main( int argc, char **argv ) { // clean up all of our zombie children int status; while ( (pid = waitpid( WAIT_ANY, &status, WNOHANG )) > 0 ) { - // cout << "waitpid(): pid = " << pid + // cout << "waitpid(): pid = " << pid // << " status = " << status << endl; } } else { diff --git a/src/Utils/poly2ogr/poly2ogr.cxx b/src/Utils/poly2ogr/poly2ogr.cxx index 9883deab..ceeec1be 100644 --- a/src/Utils/poly2ogr/poly2ogr.cxx +++ b/src/Utils/poly2ogr/poly2ogr.cxx @@ -71,7 +71,7 @@ bool endswith(const std::string& s, const std::string& suffix) { OGRLayer* create_layer(const std::string& material) { OGRLayer* layer; - + OGRSpatialReference srs; srs.SetWellKnownGeogCS("WGS84"); layer=datasource->CreateLayer(material.c_str(),&srs,wkbPolygon25D,NULL); @@ -79,27 +79,27 @@ OGRLayer* create_layer(const std::string& material) { SG_LOG(SG_GENERAL, SG_ALERT, "Creation of layer '" << material << "' failed"); return NULL; } - + OGRFieldDefn materialField("Material", OFTString); materialField.SetWidth(128); - + OGRFieldDefn fileField("File",OFTString); fileField.SetWidth(256); - + if( layer->CreateField( &materialField ) != OGRERR_NONE ) { SG_LOG(SG_GENERAL, SG_ALERT, "Creation of field 'Material' failed"); } - + if( layer->CreateField( &fileField ) != OGRERR_NONE ) { SG_LOG(SG_GENERAL, SG_ALERT, "Creation of field 'Material' failed"); } - + return layer; } OGRLayer* create_pointsLayer() { OGRLayer* layer; - + OGRSpatialReference srs; srs.SetWellKnownGeogCS("WGS84"); layer=datasource->CreateLayer("points",&srs,wkbPoint,NULL); @@ -107,21 +107,21 @@ OGRLayer* create_pointsLayer() { SG_LOG(SG_GENERAL, SG_ALERT, "Creation of layer 'points' failed"); return NULL; } - + OGRFieldDefn materialField("Material", OFTString); materialField.SetWidth(128); - + OGRFieldDefn fileField("File",OFTString); fileField.SetWidth(256); - + if( layer->CreateField( &materialField ) != OGRERR_NONE ) { SG_LOG(SG_GENERAL, SG_ALERT, "Creation of field 'Material' failed"); } - + if( layer->CreateField( &fileField ) != OGRERR_NONE ) { SG_LOG(SG_GENERAL, SG_ALERT, "Creation of field 'Material' failed"); } - + return layer; } @@ -132,7 +132,7 @@ OGRLayer* get_layer_for_material(const std::string& material) { } return defaultLayer; } - + OGRLayer* layer; LayerMap::iterator it=layerMap.find(material); if (it==layerMap.end()) { @@ -159,26 +159,26 @@ OGRLinearRing* make_ring_from_fan(const int_list& fan, const std::vectorsetX(node.x()); point->setY(node.y()); point->setZ(node.z()); - + ring->addPoint(point); } - + ring->closeRings(); - + return ring; } OGRLinearRing* make_ring_from_strip(const int_list& strip, const std::vector& nodes) { OGRLinearRing* ring = new OGRLinearRing(); const size_t vertex_count = strip.size(); - int i; + unsigned int i; for (i=0;isetX(node.x()); point->setY(node.y()); point->setZ(node.z()); - + ring->addPoint(point); } for (i--;i>0;i-=2) { @@ -187,13 +187,13 @@ OGRLinearRing* make_ring_from_strip(const int_list& strip, const std::vectorsetX(node.x()); point->setY(node.y()); point->setZ(node.z()); - + ring->addPoint(point); } std::cout << "\n"; - + ring->closeRings(); - + return ring; } @@ -204,30 +204,30 @@ void make_feature_from_polygon(OGRPolygon* polygon, const std::string& material, feature->SetField("Material", material.c_str()); feature->SetField("File", path.c_str()); feature->SetGeometry(polygon); - + if( layer->CreateFeature( feature ) != OGRERR_NONE ) { SG_LOG(SG_GENERAL, SG_ALERT, "Failed to create feature in shapefile"); } - + OGRFeature::DestroyFeature(feature); } void make_feature_from_ring(OGRLinearRing* ring, const std::string& material, const std::string& path) { OGRPolygon* polygon = new OGRPolygon(); polygon->addRingDirectly(ring); - + make_feature_from_polygon(polygon, material, path); -} +} void convert_triangles(const std::string& path, const group_list& verts, const string_list& materials, const std::vector& wgs84_nodes) { const size_t groups_count = verts.size(); - - for (int i=0;isetX(node.x()); point->setY(node.y()); point->setZ(node.z()); - + ring->addPoint(point); } ring->closeRings(); @@ -246,8 +246,8 @@ void convert_triangles(const std::string& path, const group_list& verts, const s void convert_triangle_fans(const std::string& path, const group_list& verts, const string_list& materials, const std::vector& wgs84_nodes) { const size_t groups_count = verts.size(); - - for (int i=0;i& wgs84_nodes) { const size_t groups_count = verts.size(); - - for (int i=0;i& wgs84_nodes = binObject.get_wgs84_nodes(); std::vector geod_nodes; const size_t node_count = wgs84_nodes.size(); - for (int i=0;i> contours; - + OGRPolygon* polygon=new OGRPolygon(); - + for (int contour=0;contour> count; - + if (count<3) { SG_LOG(SG_GENERAL, SG_ALERT, "Polygon with less than 3 points"); skip_ring=true; } - + in >> hole_flag; - + // FIXME: Current we ignore the hole-flag and instead assume // that the first ring is not a hole and the rest // are holes - + OGRLinearRing *ring=new OGRLinearRing(); - + for (int pt=0;pt> x >> y; point->setX(x); point->setY(y); @@ -363,51 +363,51 @@ void process_polygon_file(const std::string& path) { } else { point->setZ(0.0); } - + ring->addPoint(point); } - + ring->closeRings(); - + if (!skip_ring) polygon->addRingDirectly(ring); } - + make_feature_from_polygon(polygon, material, path); } } void process_points_file(const std::string& path) { SG_LOG(SG_GENERAL, SG_INFO, "Loading points file " << path); - + sg_gzifstream in( path ); - + if (pointsLayer==NULL) { pointsLayer=create_pointsLayer(); } - + while (!in.eof()) { std::string material; double x,y; in >> x >> y >> material; - + if (in.eof()) break; - + OGRPoint* point=new OGRPoint(x,y); - + OGRFeature* feature; feature = new OGRFeature( pointsLayer->GetLayerDefn() ); feature->SetField("Material", material.c_str()); feature->SetField("File", path.c_str()); feature->SetGeometry(point); - + if( pointsLayer->CreateFeature( feature ) != OGRERR_NONE ) { SG_LOG(SG_GENERAL, SG_ALERT, "Failed to create feature in shapefile"); } - + OGRFeature::DestroyFeature(feature); } } @@ -422,17 +422,17 @@ void process_file(const SGPath& path) BOOST_FOREACH(const SGPath& c, d.children(flags)) { process_file(c); } - + return; } - + string lext = path.complete_lower_extension(); if (lext == "pts") { process_points_file(path.str()); } else if ((lext == "btg.gz") || (lext == "btg")) { process_scenery_file(path.str()); } else if ((lext != "gz") && (lext != "arr") && (lext != "fit") && - (lext != "stg") && (lext != "ind")) + (lext != "stg") && (lext != "ind")) { // should be a polygon file process_polygon_file(path.str()); @@ -484,11 +484,11 @@ struct option options[]={ int main(int argc, char** argv) { sglog().setLogLevels( SG_ALL, SG_DEBUG ); - + OGRRegisterAll(); - + int option; - + while ((option=getopt_long(argc,argv,"hvsf:",options,NULL))!=-1) { switch (option) { case 'h': @@ -509,37 +509,37 @@ int main(int argc, char** argv) { exit(1); } } - + if (optind+1>argc) { usage(argv[0],"A datasource must be specified"); exit(1); } - + if (optind+2>argc) { usage(argv[0],"At least one input file must be specified"); exit(1); } - + const char* dst_datasource=argv[optind++]; OGRSFDriver *ogrdriver; - + ogrdriver = OGRSFDriverRegistrar::GetRegistrar()->GetDriverByName(format_name); if (!ogrdriver) { usage(argv[0],std::string("Unknown datasource format driver:")+format_name); exit(1); } - + datasource = ogrdriver->CreateDataSource(dst_datasource,NULL); if (!datasource) { usage(argv[0],std::string("Unable to create datasource:")+dst_datasource); exit(1); } - + for (int i=optind;i