| 8 | using namespace pdal; |
| 9 | |
| 10 | TEST(OGRSpecTest, createFromFile) |
| 11 | { |
| 12 | NL::json json; |
| 13 | json["type"] = "ogr"; |
| 14 | json["datasource"] = Support::datapath("autzen/attributes.json"); |
| 15 | json["drivers"] = {"GeoJSON"}; |
| 16 | json["openoptions"] = {"FLATTEN_NESTED_ATTRIBUTES=YES","NATIVE_DATA=YES"}; |
| 17 | json["sql"] = "select \"_ogr_geometry_\" from attributes"; |
| 18 | NL::json subJson; |
| 19 | subJson["dialect"] = "OGRSQL"; |
| 20 | json["options"] = subJson; |
| 21 | OGRSpec ogr(json); |
| 22 | |
| 23 | std::vector<pdal::Polygon> polys = ogr.getPolygons(); |
| 24 | |
| 25 | EXPECT_NEAR(polys[0].area(), 5.235e-06, 0.001); |
| 26 | EXPECT_NEAR(polys[1].area(), 1.450e-06, 0.001); |
| 27 | EXPECT_NEAR(polys[2].area(), 5.407e-07, 0.001); |
| 28 | EXPECT_NEAR(polys[3].area(), 4.516e-06, 0.001); |
| 29 | EXPECT_NEAR(polys[4].area(), 1.026e-06, 0.001); |
| 30 | |
| 31 | // sql selection |
| 32 | NL::json updateJson = json; |
| 33 | updateJson["sql"] = "select \"_ogr_geometry_\" from attributes WHERE id = 1"; |
| 34 | ogr.update(updateJson); |
| 35 | EXPECT_EQ(ogr.size(), 1); |
| 36 | |
| 37 | // geometry filter |
| 38 | updateJson = json; |
| 39 | subJson["geometry"] = "{\"type\":\"Polygon\",\"coordinates\":[[[-123.071871740947586, 44.058426242457685],[-123.070376025800414, 44.058117017731242],[-123.07060216253906, 44.057465769662898],[-123.072144836409578, 44.057837746292243],[-123.071871740947586, 44.058426242457685]]]}"; |
| 40 | updateJson["options"] = subJson; |
| 41 | OGRSpec ogrGeom(updateJson); |
| 42 | EXPECT_EQ(ogrGeom.size(), 1); |
| 43 | } |
| 44 | |
| 45 | TEST(OGRSpecTest, parseErrors) |
| 46 | { |