+ ogr_5th_revision.patch (kunitoki rocks!)

This commit is contained in:
Artem Pavlenko 2009-02-05 16:47:07 +00:00
parent a45e93b79a
commit 0fbfbd445a
3 changed files with 9 additions and 42 deletions

View file

@ -69,25 +69,6 @@ ogr_datasource::ogr_datasource(parameters const& params)
layer_->GetExtent (&envelope); layer_->GetExtent (&envelope);
extent_.init (envelope.MinX, envelope.MinY, envelope.MaxX, envelope.MaxY); extent_.init (envelope.MinX, envelope.MinY, envelope.MaxX, envelope.MaxY);
#if 0
double x0 = -std::numeric_limits<float>::max(),
y0 = -std::numeric_limits<float>::max(),
x1 = std::numeric_limits<float>::max(),
y1 = std::numeric_limits<float>::max();
for (int i = 0; i < dataset_->GetLayerCount (); i++)
{
OGRLayer* layer = dataset_->GetLayer (i);
layer->GetExtent (&envelope);
x0 = std::min (envelope.MinX, x0);
y0 = std::min (envelope.MinY, y0);
x1 = std::max (envelope.MaxX, x1);
y1 = std::max (envelope.MaxY, y1);
}
#endif
OGRFeatureDefn* def = layer_->GetLayerDefn (); OGRFeatureDefn* def = layer_->GetLayerDefn ();
if (def != 0) if (def != 0)
{ {

View file

@ -79,6 +79,7 @@ ogr_featureset::ogr_featureset(OGRDataSource & dataset,
bool multiple_geometries) bool multiple_geometries)
: dataset_(dataset), : dataset_(dataset),
layer_(layer), layer_(layer),
layerdef_(layer.GetLayerDefn()),
tr_(new transcoder(encoding)), tr_(new transcoder(encoding)),
fidcolumn_(layer_.GetFIDColumn ()), fidcolumn_(layer_.GetFIDColumn ()),
multiple_geometries_(multiple_geometries) multiple_geometries_(multiple_geometries)
@ -100,40 +101,39 @@ feature_ptr ogr_featureset::next()
convert_geometry (geom, feature); convert_geometry (geom, feature);
OGRFeatureDefn* def = layer_.GetLayerDefn(); int fld_count = layerdef_->GetFieldCount();
int fld_count = def->GetFieldCount();
for (int i = 0; i < fld_count; i++) for (int i = 0; i < fld_count; i++)
{ {
OGRFieldDefn* fld = def->GetFieldDefn (i); OGRFieldDefn* fld = layerdef_->GetFieldDefn (i);
OGRFieldType type_oid = fld->GetType (); OGRFieldType type_oid = fld->GetType ();
std_string name = fld->GetNameRef (); std_string fld_name = fld->GetNameRef ();
switch (type_oid) switch (type_oid)
{ {
case OFTInteger: case OFTInteger:
{ {
boost::put(*feature,name,(*feat)->GetFieldAsInteger (i)); boost::put(*feature,fld_name,(*feat)->GetFieldAsInteger (i));
break; break;
} }
case OFTReal: case OFTReal:
{ {
boost::put(*feature,name,(*feat)->GetFieldAsDouble (i)); boost::put(*feature,fld_name,(*feat)->GetFieldAsDouble (i));
break; break;
} }
case OFTString: case OFTString:
case OFTWideString: // deprecated ! case OFTWideString: // deprecated !
case OFTWideStringList: // deprecated !
{ {
UnicodeString ustr = tr_->transcode((*feat)->GetFieldAsString (i)); UnicodeString ustr = tr_->transcode((*feat)->GetFieldAsString (i));
boost::put(*feature,name,ustr); boost::put(*feature,fld_name,ustr);
break; break;
} }
case OFTIntegerList: case OFTIntegerList:
case OFTRealList: case OFTRealList:
case OFTStringList: case OFTStringList:
case OFTWideStringList: // deprecated !
{ {
#ifdef MAPNIK_DEBUG #ifdef MAPNIK_DEBUG
clog << "unhandled type_oid=" << type_oid << endl; clog << "unhandled type_oid=" << type_oid << endl;
@ -177,12 +177,6 @@ feature_ptr ogr_featureset::next()
return feature_ptr(); return feature_ptr();
} }
int ogr_featureset::endian()
{
const int t = 1;
return (*(char*)&t == 0) ? wkbXDR : wkbNDR;
}
void ogr_featureset::convert_geometry (OGRGeometry* geom, feature_ptr feature) void ogr_featureset::convert_geometry (OGRGeometry* geom, feature_ptr feature)
{ {
switch (wkbFlatten (geom->getGeometryType())) switch (wkbFlatten (geom->getGeometryType()))
@ -409,11 +403,3 @@ void ogr_featureset::convert_collection (OGRGeometryCollection* geom, feature_pt
} }
} }
/*
int size=geom->WkbSize ();
char data[size];
geom->exportToWkb ((OGRwkbByteOrder) endian(), reinterpret_cast<unsigned char*>(&data[0]));
geometry_utils::from_wkb (*feature, &data[0], size, multiple_geometries_);
*/

View file

@ -44,7 +44,6 @@ class ogr_featureset : public mapnik::Featureset
virtual ~ogr_featureset(); virtual ~ogr_featureset();
mapnik::feature_ptr next(); mapnik::feature_ptr next();
private: private:
int endian();
void convert_geometry (OGRGeometry* geom, mapnik::feature_ptr feature); void convert_geometry (OGRGeometry* geom, mapnik::feature_ptr feature);
void convert_point (OGRPoint* geom, mapnik::feature_ptr feature); void convert_point (OGRPoint* geom, mapnik::feature_ptr feature);
void convert_linestring (OGRLineString* geom, mapnik::feature_ptr feature); void convert_linestring (OGRLineString* geom, mapnik::feature_ptr feature);
@ -58,6 +57,7 @@ class ogr_featureset : public mapnik::Featureset
void convert_collection (OGRGeometryCollection* geom, mapnik::feature_ptr feature); void convert_collection (OGRGeometryCollection* geom, mapnik::feature_ptr feature);
OGRDataSource & dataset_; OGRDataSource & dataset_;
OGRLayer & layer_; OGRLayer & layer_;
OGRFeatureDefn * layerdef_;
boost::scoped_ptr<mapnik::transcoder> tr_; boost::scoped_ptr<mapnik::transcoder> tr_;
const char* fidcolumn_; const char* fidcolumn_;
bool multiple_geometries_; bool multiple_geometries_;