1
0
Fork 0

[ogr-decode] source code format only.

This commit is contained in:
Scott Giese 2019-04-23 11:51:05 -05:00
parent 6a00e62e08
commit 3e0ecec965

View file

@ -23,24 +23,24 @@
//
#include <chrono>
#include <string>
#include <map>
#include <string>
#include <boost/thread.hpp>
#include <ogrsf_frmts.h>
#include <gdal_priv.h>
#include <ogrsf_frmts.h>
#include <simgear/compiler.h>
#include <simgear/threads/SGThread.hxx>
#include <simgear/threads/SGQueue.hxx>
#include <simgear/debug/logstream.hxx>
#include <simgear/math/sg_geodesy.hxx>
#include <simgear/misc/sg_path.hxx>
#include <simgear/threads/SGQueue.hxx>
#include <simgear/threads/SGThread.hxx>
#include <Include/version.h>
#include <terragear/tg_polygon.hxx>
#include <terragear/tg_chopper.hxx>
#include <terragear/tg_polygon.hxx>
#include <terragear/tg_shapefile.hxx>
/* stretch endpoints to reduce slivers in linear data ~.1 meters */
@ -74,22 +74,26 @@ const double gSnap = 0.00000001; // approx 1 mm
SGLockedQueue<OGRFeature*> global_workQueue;
/* very GDAL specific here... */
inline static bool is_ocean_area( const std::string &area ) {
inline static bool is_ocean_area(const std::string& area)
{
return area == "Ocean" || area == "Bay Estuary or Ocean";
}
inline static bool is_void_area( const std::string &area ) {
inline static bool is_void_area(const std::string& area)
{
return area == "Void Area";
}
inline static bool is_null_area( const std::string& area ) {
inline static bool is_null_area(const std::string& area)
{
return area == "Null";
}
class Decoder : public SGThread
{
class Decoder : public SGThread {
public:
Decoder( OGRCoordinateTransformation *poct, int atf, int pwf, int lwf, tgChopper& c ) : chopper(c) {
Decoder(OGRCoordinateTransformation* poct, int atf, int pwf, int lwf, tgChopper& c)
: chopper(c)
{
poCT = poct;
area_type_field = atf;
point_width_field = pwf;
@ -160,24 +164,20 @@ void Decoder::processLineString(OGRLineString* poGeometry, const string& area_ty
p1 = SGGeod::fromDeg(poGeometry->getX(i), poGeometry->getY(i));
SGGeodesy::inverse(p0, p1, heading, az2, dist);
if (dist > max_dist)
{
if (dist > max_dist) {
numSegs = (dist / max_dist) + 1;
dist = dist / (double)numSegs;
for (j=0; j<numSegs; j++)
{
for (j = 0; j < numSegs; j++) {
line.AddNode(SGGeodesy::direct(p0, heading, dist * (j + 1)));
}
}
else
{
} else {
line.AddNode(p1);
}
}
// then stretch the last point
// because vector data can generate adjacent polys, lets stretch the two enpoints by a little bit
// because vector data can generate adjacent polys, lets stretch the two endpoints by a little bit
p0 = SGGeod::fromDeg(poGeometry->getX(numPoints - 2), poGeometry->getY(numPoints - 2));
p1 = SGGeod::fromDeg(poGeometry->getX(numPoints - 1), poGeometry->getY(numPoints - 1));
@ -188,11 +188,13 @@ void Decoder::processLineString(OGRLineString* poGeometry, const string& area_ty
int texturing;
if (with_texture) {
texturing = TG_TEX_BY_TPS_CLIPU;
}
else {
} else {
texturing = TG_TEX_BY_GEODE;
}
if ( texture_cliffs ) texturing = TG_TEX_BY_HORIZ_REF;
if (texture_cliffs)
texturing = TG_TEX_BY_HORIZ_REF;
segments = tgContour::ExpandToPolygons(line, width, texturing);
for (unsigned int i = 0; i < segments.size(); ++i) {
segments[i].SetPreserve3D(false);
@ -238,9 +240,8 @@ void Decoder::run()
}
OGRwkbGeometryType geoType = wkbFlatten(poGeometry->getGeometryType());
if (geoType!=wkbPoint && geoType!=wkbMultiPoint &&
geoType!=wkbLineString && geoType!=wkbMultiLineString &&
geoType!=wkbPolygon && geoType!=wkbMultiPolygon) {
if (geoType != wkbPoint && geoType != wkbMultiPoint && geoType != wkbLineString &&
geoType != wkbMultiLineString && geoType != wkbPolygon && geoType != wkbMultiPolygon) {
SG_LOG(SG_GENERAL, SG_INFO, "Unknown feature");
continue;
}
@ -330,7 +331,8 @@ void Decoder::run()
OGRMultiLineString* multilines = (OGRMultiLineString*)poGeometry;
for (int i = 0; i < multilines->getNumGeometries(); ++i) {
processLineString((OGRLineString*)(multilines->getGeometryRef(i)), area_type_name, width, texture_lines, texture_cliffs);
processLineString((OGRLineString*)(multilines->getGeometryRef(i)), area_type_name, width,
texture_lines, texture_cliffs);
}
break;
}
@ -367,8 +369,7 @@ void processLayer(OGRLayer* poLayer, tgChopper& results )
if (!continue_on_errors) {
SG_LOG(SG_GENERAL, SG_ALERT, "Aborting!");
exit(1);
}
else
} else
return;
}
@ -384,8 +385,7 @@ void processLayer(OGRLayer* poLayer, tgChopper& results )
if (!continue_on_errors) {
SG_LOG(SG_GENERAL, SG_ALERT, "Aborting!");
exit(1);
}
else
} else
return;
}
}
@ -397,8 +397,7 @@ void processLayer(OGRLayer* poLayer, tgChopper& results )
if (!continue_on_errors) {
SG_LOG(SG_GENERAL, SG_ALERT, "Aborting!");
exit(1);
}
else
} else
return;
}
}
@ -410,8 +409,7 @@ void processLayer(OGRLayer* poLayer, tgChopper& results )
if (!continue_on_errors) {
SG_LOG(SG_GENERAL, SG_ALERT, "Aborting!");
exit(1);
}
else
} else
return;
}
}
@ -424,8 +422,7 @@ void processLayer(OGRLayer* poLayer, tgChopper& results )
if (!continue_on_errors) {
SG_LOG(SG_GENERAL, SG_ALERT, "Aborting!");
exit(1);
}
else
} else
return;
}
@ -465,8 +462,7 @@ void processLayer(OGRLayer* poLayer, tgChopper& results )
SG_LOG(SG_GENERAL, SG_ALERT, "Aborting!");
OCTDestroyCoordinateTransformation(poCT);
exit(1);
}
else
} else
return;
}
}
@ -474,8 +470,7 @@ void processLayer(OGRLayer* poLayer, tgChopper& results )
// Generate the work queue for this layer
OGRFeature* poFeature;
poLayer->SetNextByIndex(start_record);
while ( ( poFeature = poLayer->GetNextFeature()) != NULL )
{
while ((poFeature = poLayer->GetNextFeature()) != NULL) {
global_workQueue.push(poFeature);
}
@ -496,9 +491,9 @@ void processLayer(OGRLayer* poLayer, tgChopper& results )
OCTDestroyCoordinateTransformation(poCT);
}
void usage(char* progname) {
SG_LOG( SG_GENERAL, SG_ALERT, "Usage: " <<
progname << " [options...] <work_dir> <datasource> [<layername>...]" );
void usage(char* progname)
{
SG_LOG(SG_GENERAL, SG_ALERT, "Usage: " << progname << " [options...] <work_dir> <datasource> [<layername>...]");
SG_LOG(SG_GENERAL, SG_ALERT, "Options:");
SG_LOG(SG_GENERAL, SG_ALERT, "--log-level priority");
SG_LOG(SG_GENERAL, SG_ALERT, " Width in priority being bulk|debug|info|warn|alert");
@ -543,15 +538,17 @@ void usage(char* progname) {
SG_LOG(SG_GENERAL, SG_ALERT, "<layername>...");
SG_LOG(SG_GENERAL, SG_ALERT, " The layers to process.");
SG_LOG(SG_GENERAL, SG_ALERT, " If no layer is given, all layers in the datasource are used");
exit(-1);
}
void
setLoggingPriority (const char * p)
void setLoggingPriority(const char* p)
{
if (p == 0)
return;
string priority = p;
if (priority == "bulk") {
sglog().set_log_priority(SG_BULK);
} else if (priority == "debug") {
@ -567,7 +564,8 @@ setLoggingPriority (const char * p)
}
}
int main( int argc, char **argv ) {
int main(int argc, char** argv)
{
char* progname = argv[0];
string datasource, work_dir;
@ -724,8 +722,7 @@ int main( int argc, char **argv ) {
GDALDataset* poDS;
poDS = (GDALDataset*)GDALOpenEx(datasource.c_str(), GDAL_OF_VECTOR, NULL, NULL, NULL);
if ( poDS == NULL )
{
if (poDS == NULL) {
SG_LOG(SG_GENERAL, SG_ALERT, "Failed opening datasource " << datasource);
GDALDestroyDriverManager();
@ -739,8 +736,7 @@ int main( int argc, char **argv ) {
if (argc > 3) {
for (int i = 3; i < argc; ++i) {
poLayer = poDS->GetLayerByName(argv[i]);
if (poLayer == NULL )
{
if (poLayer == NULL) {
SG_LOG(SG_GENERAL, SG_ALERT, "Failed opening layer " << argv[i] << " from datasource " << datasource);
return EXIT_FAILURE;
}
@ -765,7 +761,9 @@ int main( int argc, char **argv ) {
auto finish_time = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> elapsed = finish_time - start_time;
std::cout << std::endl << "Elapsed time: " << elapsed.count() << " seconds" << std::endl << std::endl;
std::cout << std::endl
<< "Elapsed time: " << elapsed.count() << " seconds" << std::endl
<< std::endl;
return EXIT_SUCCESS;
}