Skip to content

Commit

Permalink
commented out shapefile
Browse files Browse the repository at this point in the history
  • Loading branch information
denizdiktas committed Jul 23, 2023
1 parent 3009fc4 commit db132c3
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 58 deletions.
1 change: 0 additions & 1 deletion Arrangement_on_surface_2/demo/earth/Main_widget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -272,7 +272,6 @@ void Main_widget::init_country_borders(float error)
// TO-DO: move this code to resizeGL (when viewport is initialized)
// has to be defined after camera has been defined:
// because we want to compute the error based on camera parameters!
//Geodesic_arcs ga;
//const double error = 0.001; // calculate this from cam parameters!
//auto lsa = Aos::get_approx_arcs(countries, error);
//auto lsa = Aos::get_approx_arcs(error);
Expand Down
86 changes: 43 additions & 43 deletions Arrangement_on_surface_2/demo/earth/Shapefile.cpp
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@

#include "Shapefile.h"

#include <iostream>

#include <shapefil.h>


void Shapefile::read(const std::string& filename)
{
// Open the shapefile
SHPHandle shp = SHPOpen(filename.c_str(), "rb");
if (shp == nullptr) {
std::cerr << "Failed to open shapefile: " << filename << std::endl;
return;
}

// Get shapefile information
int numEntities, shapeType;
double minBounds[4], maxBounds[4];
SHPGetInfo(shp, &numEntities, &shapeType, minBounds, maxBounds);
std::cout << "Number of entities: " << numEntities << std::endl;
std::cout << "Shape type: " << shapeType << std::endl;
std::cout << "Bounds: (" << minBounds[0] << ", " << minBounds[1] << "), ("
<< maxBounds[0] << ", " << maxBounds[1] << ")" << std::endl;
//SHPT_POLYGON
// Read individual shapes
for (int i = 0; i < numEntities; ++i) {
SHPObject* shape = SHPReadObject(shp, i);

// Process the shape data
// Example: Print the shape's type and number of points
std::cout << "Shape " << i << ": Type " << shape->nSHPType
<< ", Number of parts: " << shape->nParts
<< ", Number of points: " << shape->nVertices << std::endl;

// Clean up the shape object
SHPDestroyObject(shape);
}

// Close the shapefile
SHPClose(shp);
}
//
//#include "Shapefile.h"
//
//#include <iostream>
//
//#include <shapefil.h>
//
//
//void Shapefile::read(const std::string& filename)
//{
// // Open the shapefile
// SHPHandle shp = SHPOpen(filename.c_str(), "rb");
// if (shp == nullptr) {
// std::cerr << "Failed to open shapefile: " << filename << std::endl;
// return;
// }
//
// // Get shapefile information
// int numEntities, shapeType;
// double minBounds[4], maxBounds[4];
// SHPGetInfo(shp, &numEntities, &shapeType, minBounds, maxBounds);
// std::cout << "Number of entities: " << numEntities << std::endl;
// std::cout << "Shape type: " << shapeType << std::endl;
// std::cout << "Bounds: (" << minBounds[0] << ", " << minBounds[1] << "), ("
// << maxBounds[0] << ", " << maxBounds[1] << ")" << std::endl;
// //SHPT_POLYGON
// // Read individual shapes
// for (int i = 0; i < numEntities; ++i) {
// SHPObject* shape = SHPReadObject(shp, i);
//
// // Process the shape data
// // Example: Print the shape's type and number of points
// std::cout << "Shape " << i << ": Type " << shape->nSHPType
// << ", Number of parts: " << shape->nParts
// << ", Number of points: " << shape->nVertices << std::endl;
//
// // Clean up the shape object
// SHPDestroyObject(shape);
// }
//
// // Close the shapefile
// SHPClose(shp);
//}
28 changes: 14 additions & 14 deletions Arrangement_on_surface_2/demo/earth/Shapefile.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@

#ifndef SHAPEFILE_H
#define SHAPEFILE_H

#include <string>


class Shapefile
{
public:
static void read(const std::string& filename);
};

#endif
//
//#ifndef SHAPEFILE_H
//#define SHAPEFILE_H
//
//#include <string>
//
//
//class Shapefile
//{
//public:
// static void read(const std::string& filename);
//};
//
//#endif

0 comments on commit db132c3

Please sign in to comment.