-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3009fc4
commit db132c3
Showing
3 changed files
with
57 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
//} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |