Skip to content

Commit

Permalink
Use the C++ API
Browse files Browse the repository at this point in the history
  • Loading branch information
e-n-f committed May 1, 2024
1 parent 32785a3 commit fd26593
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions overzoom.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,21 @@ void usage(char **argv) {
exit(EXIT_FAILURE);
}

mvt_tile gdal_to_tile(OGRLayerH poLayer) {
OGRFeatureDefnH poFDefn = OGR_L_GetLayerDefn(poLayer);
mvt_tile gdal_to_tile(OGRLayer *poLayer) {
OGRFeatureDefn *poFDefn = poLayer->GetLayerDefn();
mvt_tile ret;

OGRFeatureH poFeature;
while ((poFeature = OGR_L_GetNextFeature(poLayer)) != NULL) {
// close feature
OGRFeature *poFeature;
while ((poFeature = poLayer->GetNextFeature()) != NULL) {
// ...
OGRFeature::DestroyFeature(poFeature);
}

// close defn

// defn is owned by the layer, doesn't need to be closed
return ret;
}

int main(int argc, char **argv) {
GDALAllRegister();

int i;
const char *outfile = NULL;
bool gdal_input = false;
Expand Down Expand Up @@ -169,7 +167,6 @@ int main(int argc, char **argv) {
}

std::string out;

if (gdal_input) {
GDALAllRegister();
GDALDataset *poDS = static_cast<GDALDataset *>(GDALOpenEx(infile, GDAL_OF_VECTOR, NULL, NULL, NULL));
Expand All @@ -178,16 +175,19 @@ int main(int argc, char **argv) {
exit(EXIT_OPEN);
}

OGRLayerH poLayer;
OGRLayer *poLayer;
mvt_tile tile;
if (gdal_sql.size() == 0) {
poLayer = GDALDatasetGetLayer(poDS, 0);
poLayer = poDS->GetLayer(0);
tile = gdal_to_tile(poLayer);
// layer is owned by the dataset, doesn't need to be closed
} else {
poLayer = GDALDatasetExecuteSQL(poDS, gdal_sql.c_str(), NULL, NULL);
poLayer = poDS->ExecuteSQL(gdal_sql.c_str(), NULL, NULL);
tile = gdal_to_tile(poLayer);
poDS->ReleaseResultSet(poLayer);
}

mvt_tile tile = gdal_to_tile(poLayer);
// XXX close layer
// XXX close dataset
GDALClose(poDS);

out = overzoom(tile, oz, ox, oy, nz, nx, ny, detail, buffer, keep, true, NULL, demultiply, json_filter, preserve_input_order, attribute_accum, unidecode_data);
} else {
Expand Down

0 comments on commit fd26593

Please sign in to comment.