Advertisement
Guest User

Untitled

a guest
Aug 1st, 2014
280
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.92 KB | None | 0 0
  1. {
  2.    OGRRegisterAll();
  3.  
  4.    OGRDataSource       *poDS;
  5.  
  6.    poDS = OGRSFDriverRegistrar::Open("C:\\projects\\osgearth\\data\\shapefiles_dresden", FALSE);
  7.    if (poDS == NULL)
  8.    {
  9.       printf("Open failed.\n");
  10.       exit(1);
  11.    }
  12.  
  13.    OGRLayer  *poLayer;
  14.  
  15.    poLayer = poDS->GetLayerByName("gis.osm_pois_v06");
  16.  
  17.    OGRFeature *poFeature;
  18.  
  19.    OGRPolygon* polygon = new OGRPolygon();
  20.    OGRLinearRing* ring = new OGRLinearRing();
  21.  
  22.    ring->addPoint(51.089028, 13.617821);
  23.    ring->addPoint(51.089675, 13.807336);
  24.    ring->addPoint(51.025585, 13.807679);
  25.    ring->addPoint(51.024937, 13.616105);
  26.  
  27.    polygon->addRing(ring);
  28.  
  29.    poLayer->SetSpatialFilter(polygon);
  30.  
  31.    poLayer->ResetReading();
  32.    while ((poFeature = poLayer->GetNextFeature()) != NULL)
  33.    {
  34.       OGRFeatureDefn *poFDefn = poLayer->GetLayerDefn();
  35.  
  36.       OGRFeature::DestroyFeature(poFeature);
  37.    }
  38.  
  39.    OGRDataSource::DestroyDataSource(poDS);
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement