fix ogr-decode double save issue
- added some experimental (and unused) iterative tests
This commit is contained in:
parent
08f5c17221
commit
a74edcd91b
5 changed files with 118 additions and 113 deletions
|
@ -9,7 +9,7 @@
|
||||||
|
|
||||||
#include "tg_chopper.hxx"
|
#include "tg_chopper.hxx"
|
||||||
|
|
||||||
void tgChopper::Clip( const tgPolygon& subject,
|
tgPolygon tgChopper::Clip( const tgPolygon& subject,
|
||||||
const std::string& type,
|
const std::string& type,
|
||||||
SGBucket& b )
|
SGBucket& b )
|
||||||
{
|
{
|
||||||
|
@ -42,24 +42,12 @@ void tgChopper::Clip( const tgPolygon& subject,
|
||||||
base.AddNode( 0, SGGeod::fromDeg( max.getLongitudeDeg(), max.getLatitudeDeg()) );
|
base.AddNode( 0, SGGeod::fromDeg( max.getLongitudeDeg(), max.getLatitudeDeg()) );
|
||||||
base.AddNode( 0, SGGeod::fromDeg( min.getLongitudeDeg(), max.getLatitudeDeg()) );
|
base.AddNode( 0, SGGeod::fromDeg( min.getLongitudeDeg(), max.getLatitudeDeg()) );
|
||||||
|
|
||||||
SG_LOG(SG_GENERAL, SG_DEBUG, "shape contours = " << subject.Contours() );
|
|
||||||
for ( unsigned int ii = 0; ii < subject.Contours(); ii++ ) {
|
|
||||||
SG_LOG(SG_GENERAL, SG_DEBUG, " hole = " << subject.GetContour(ii).GetHole() );
|
|
||||||
}
|
|
||||||
|
|
||||||
result = tgPolygon::Intersect( subject, base );
|
result = tgPolygon::Intersect( subject, base );
|
||||||
|
if ( result.Contours() > 0 ) {
|
||||||
SG_LOG(SG_GENERAL, SG_DEBUG, "result contours = " << result.Contours() );
|
|
||||||
for ( unsigned int ii = 0; ii < result.Contours(); ii++ ) {
|
|
||||||
SG_LOG(SG_GENERAL, SG_DEBUG, " hole = " << result.GetContour(ii).GetHole() );
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( subject.GetPreserve3D() ) {
|
if ( subject.GetPreserve3D() ) {
|
||||||
result.InheritElevations( subject );
|
result.InheritElevations( subject );
|
||||||
|
result.SetPreserve3D( true );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( result.Contours() > 0 ) {
|
|
||||||
result.SetPreserve3D( subject.GetPreserve3D() );
|
|
||||||
result.SetTexParams( subject.GetTexParams() );
|
result.SetTexParams( subject.GetTexParams() );
|
||||||
if ( subject.GetTexMethod() == TG_TEX_BY_GEODE ) {
|
if ( subject.GetTexMethod() == TG_TEX_BY_GEODE ) {
|
||||||
// need to set center latitude for geodetic texturing
|
// need to set center latitude for geodetic texturing
|
||||||
|
@ -71,6 +59,8 @@ void tgChopper::Clip( const tgPolygon& subject,
|
||||||
bp_map[b.gen_index()].push_back( result );
|
bp_map[b.gen_index()].push_back( result );
|
||||||
lock.unlock();
|
lock.unlock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void tgChopper::Add( const tgPolygon& subject, const std::string& type )
|
void tgChopper::Add( const tgPolygon& subject, const std::string& type )
|
||||||
|
@ -97,9 +87,7 @@ void tgChopper::Add( const tgPolygon& subject, const std::string& type )
|
||||||
if ( b_min == b_max ) {
|
if ( b_min == b_max ) {
|
||||||
// shape entirely contained in a single bucket, write and bail
|
// shape entirely contained in a single bucket, write and bail
|
||||||
Clip( subject, type, b_min );
|
Clip( subject, type, b_min );
|
||||||
return;
|
} else {
|
||||||
}
|
|
||||||
|
|
||||||
SGBucket b_cur;
|
SGBucket b_cur;
|
||||||
int dx, dy;
|
int dx, dy;
|
||||||
|
|
||||||
|
@ -186,8 +174,8 @@ void tgChopper::Add( const tgPolygon& subject, const std::string& type )
|
||||||
|
|
||||||
if ( (top_clip.TotalNodes() > 0) && (top_clip.TotalNodes() != subject.TotalNodes()) ) {
|
if ( (top_clip.TotalNodes() > 0) && (top_clip.TotalNodes() != subject.TotalNodes()) ) {
|
||||||
Add( top_clip, type );
|
Add( top_clip, type );
|
||||||
} else
|
}
|
||||||
return;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,7 +18,7 @@ public:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
long int GenerateIndex( std::string path );
|
long int GenerateIndex( std::string path );
|
||||||
void Clip( const tgPolygon& subject, const std::string& type, SGBucket& b );
|
tgPolygon Clip( const tgPolygon& subject, const std::string& type, SGBucket& b );
|
||||||
void Chop( const tgPolygon& subject, const std::string& type );
|
void Chop( const tgPolygon& subject, const std::string& type );
|
||||||
|
|
||||||
std::string root_path;
|
std::string root_path;
|
||||||
|
|
|
@ -36,6 +36,23 @@ void tgRectangle::setMax (const SGGeod &p)
|
||||||
_max = p;
|
_max = p;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void tgRectangle::expandBy(const tgRectangle& r)
|
||||||
|
{
|
||||||
|
if ( r.getMin().getLongitudeDeg() < _min.getLongitudeDeg() ) {
|
||||||
|
_min.setLongitudeDeg( r.getMin().getLongitudeDeg() );
|
||||||
|
}
|
||||||
|
if ( r.getMin().getLatitudeDeg() < _min.getLatitudeDeg() ) {
|
||||||
|
_min.setLatitudeDeg( r.getMin().getLatitudeDeg() );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( r.getMax().getLongitudeDeg() > _max.getLongitudeDeg() ) {
|
||||||
|
_max.setLongitudeDeg( r.getMax().getLongitudeDeg() );
|
||||||
|
}
|
||||||
|
if ( r.getMax().getLatitudeDeg() > _max.getLatitudeDeg() ) {
|
||||||
|
_max.setLatitudeDeg( r.getMax().getLatitudeDeg() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void tgRectangle::sanify ()
|
void tgRectangle::sanify ()
|
||||||
{
|
{
|
||||||
double tmp;
|
double tmp;
|
||||||
|
|
|
@ -90,6 +90,13 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void setMax (const SGGeod& p);
|
virtual void setMax (const SGGeod& p);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Expand the rectangle to encompass a given rectangle
|
||||||
|
*
|
||||||
|
* @param r The rectangle to expand by
|
||||||
|
*/
|
||||||
|
virtual void expandBy(const tgRectangle& r);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Make the rectangle sane.
|
* Make the rectangle sane.
|
||||||
*
|
*
|
||||||
|
|
|
@ -212,6 +212,8 @@ void Decoder::run()
|
||||||
// as long as we have geometry to parse, do so
|
// as long as we have geometry to parse, do so
|
||||||
while (!global_workQueue.empty()) {
|
while (!global_workQueue.empty()) {
|
||||||
OGRFeature *poFeature = global_workQueue.pop();
|
OGRFeature *poFeature = global_workQueue.pop();
|
||||||
|
// SG_LOG( SG_GENERAL, SG_INFO, " remaining features is " << global_workQueue.size() );
|
||||||
|
|
||||||
if ( poFeature ) {
|
if ( poFeature ) {
|
||||||
OGRGeometry *poGeometry = poFeature->GetGeometryRef();
|
OGRGeometry *poGeometry = poFeature->GetGeometryRef();
|
||||||
|
|
||||||
|
@ -315,9 +317,9 @@ void Decoder::run()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
OGRMultiLineString* multils=(OGRMultiLineString*)poGeometry;
|
OGRMultiLineString* multilines=(OGRMultiLineString*)poGeometry;
|
||||||
for (int i=0;i<multils->getNumGeometries();i++) {
|
for (int i=0;i<multilines->getNumGeometries();i++) {
|
||||||
processLineString((OGRLineString*)poGeometry, area_type_name, width, texture_lines);
|
processLineString((OGRLineString*)(multilines->getGeometryRef(i)), area_type_name, width, texture_lines);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -388,9 +390,7 @@ void processLayer(OGRLayer* poLayer, tgChopper& results )
|
||||||
|
|
||||||
/* setup a transformation to WGS84 */
|
/* setup a transformation to WGS84 */
|
||||||
OGRSpatialReference *oSourceSRS, oTargetSRS;
|
OGRSpatialReference *oSourceSRS, oTargetSRS;
|
||||||
|
|
||||||
oSourceSRS=poLayer->GetSpatialRef();
|
oSourceSRS=poLayer->GetSpatialRef();
|
||||||
|
|
||||||
if (oSourceSRS == NULL) {
|
if (oSourceSRS == NULL) {
|
||||||
SG_LOG( SG_GENERAL, SG_ALERT, "Layer " << layername << " has no defined spatial reference system" );
|
SG_LOG( SG_GENERAL, SG_ALERT, "Layer " << layername << " has no defined spatial reference system" );
|
||||||
exit( 1 );
|
exit( 1 );
|
||||||
|
@ -441,6 +441,7 @@ void processLayer(OGRLayer* poLayer, tgChopper& results )
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now process the workqueue with threads
|
// Now process the workqueue with threads
|
||||||
|
// this just generates all the tgPolygons
|
||||||
std::vector<Decoder *> decoders;
|
std::vector<Decoder *> decoders;
|
||||||
for (int i=0; i<num_threads; i++) {
|
for (int i=0; i<num_threads; i++) {
|
||||||
Decoder* decoder = new Decoder( poCT, area_type_field, point_width_field, line_width_field, results );
|
Decoder* decoder = new Decoder( poCT, area_type_field, point_width_field, line_width_field, results );
|
||||||
|
@ -448,19 +449,11 @@ void processLayer(OGRLayer* poLayer, tgChopper& results )
|
||||||
decoders.push_back( decoder );
|
decoders.push_back( decoder );
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
while (!global_workQueue.empty()) {
|
|
||||||
sleep(1);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
|
|
||||||
// Then wait until they are finished
|
// Then wait until they are finished
|
||||||
for (unsigned int i=0; i<decoders.size(); i++) {
|
for (unsigned int i=0; i<decoders.size(); i++) {
|
||||||
decoders[i]->join();
|
decoders[i]->join();
|
||||||
}
|
}
|
||||||
|
|
||||||
results.Save();
|
|
||||||
|
|
||||||
OCTDestroyCoordinateTransformation ( poCT );
|
OCTDestroyCoordinateTransformation ( poCT );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -659,7 +652,6 @@ int main( int argc, char **argv ) {
|
||||||
SG_LOG( SG_GENERAL, SG_ALERT, "Processing datasource " << datasource );
|
SG_LOG( SG_GENERAL, SG_ALERT, "Processing datasource " << datasource );
|
||||||
|
|
||||||
OGRLayer *poLayer;
|
OGRLayer *poLayer;
|
||||||
|
|
||||||
if (argc>3) {
|
if (argc>3) {
|
||||||
for (int i=3;i<argc;i++) {
|
for (int i=3;i<argc;i++) {
|
||||||
poLayer = poDS->GetLayerByName( argv[i] );
|
poLayer = poDS->GetLayerByName( argv[i] );
|
||||||
|
@ -681,9 +673,10 @@ int main( int argc, char **argv ) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
results.Save();
|
|
||||||
|
|
||||||
OGRDataSource::DestroyDataSource( poDS );
|
OGRDataSource::DestroyDataSource( poDS );
|
||||||
|
|
||||||
|
SG_LOG(SG_GENERAL, SG_ALERT, "Saving to buckets");
|
||||||
|
results.Save();
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue