inline boost::polygon transform::proj_to_pixel(const boost::box& env) const { using namespace std; using namespace brig::boost; const double xmin(env.min_corner().get<0>()), ymin(env.min_corner().get<1>()), xmax(env.max_corner().get<0>()), ymax(env.max_corner().get<1>()); polygon poly; ::boost::geometry::append(poly, point(to_p(xmin, ymax), to_l(xmin, ymax))); ::boost::geometry::append(poly, point(to_p(xmin, ymin), to_l(xmin, ymin))); ::boost::geometry::append(poly, point(to_p(xmax, ymin), to_l(xmax, ymin))); ::boost::geometry::append(poly, point(to_p(xmax, ymax), to_l(xmax, ymax))); ::boost::geometry::append(poly, point(to_p(xmin, ymax), to_l(xmin, ymax))); return poly; }
inline boost::polygon transform::pixel_to_proj(const boost::box& env) const { using namespace std; using namespace brig::boost; const double pmin(env.min_corner().get<0>()), lmin(env.min_corner().get<1>()), pmax(env.max_corner().get<0>()), lmax(env.max_corner().get<1>()); polygon poly; ::boost::geometry::append(poly, point(to_x(pmin, lmax), to_y(pmin, lmax))); ::boost::geometry::append(poly, point(to_x(pmax, lmax), to_y(pmax, lmax))); ::boost::geometry::append(poly, point(to_x(pmax, lmin), to_y(pmax, lmin))); ::boost::geometry::append(poly, point(to_x(pmin, lmin), to_y(pmin, lmin))); ::boost::geometry::append(poly, point(to_x(pmin, lmax), to_y(pmin, lmax))); return poly; }
inline std::string dialect_db2::sql_intersect(const table_def& tbl, const std::string& col, const boost::box& box) { using namespace std; const double xmin(box.min_corner().get<0>()), ymin(box.min_corner().get<1>()), xmax(box.max_corner().get<0>()), ymax(box.max_corner().get<1>()); ostringstream stream; stream.imbue(locale::classic()); stream << scientific; stream.precision(17); stream << "DB2GSE.EnvelopesIntersect(" << sql_identifier(col) << ", " << xmin << ", " << ymin << ", " << xmax << ", " << ymax << ", " << tbl[col]->srid << ") = 1"; return stream.str(); } // dialect_db2::
inline std::string dialect_ms_sql::sql_intersect(const table_def& tbl, const std::string& col, const boost::box& box) { using namespace std; const double xmin(box.min_corner().get<0>()), ymin(box.min_corner().get<1>()), xmax(box.max_corner().get<0>()), ymax(box.max_corner().get<1>()); auto col_def(tbl[col]); const bool geography(col_def->type_lcase.name.compare("geography") == 0); ostringstream stream; stream.imbue(locale::classic()); stream << scientific; stream.precision(17); stream << "" << sql_identifier(col) << ".Filter("; if (geography) stream << "geography::STGeomFromWKB("; stream << "geometry::Point(" << xmin << ", " << ymin << ", " << col_def->srid << ").STUnion(geometry::Point(" << xmax << ", " << ymax << ", " << col_def->srid << ")).STEnvelope()"; if (geography) stream << ".STAsBinary(), " << col_def->srid << ")"; stream << ") = 1"; return stream.str(); } // dialect_ms_sql::
inline std::string dialect_postgres::sql_intersect(const table_def& tbl, const std::string& col, const boost::box& box) { using namespace std; const double xmin(box.min_corner().get<0>()), ymin(box.min_corner().get<1>()), xmax(box.max_corner().get<0>()), ymax(box.max_corner().get<1>()); auto col_def(tbl[col]); bool geography(false), raster(false); if (col_def->type_lcase.name.compare("raster") == 0) raster = true; else if (col_def->type_lcase.name.compare("geography") == 0) geography = true; else if (col_def->type_lcase.name.compare("geometry") != 0) throw runtime_error("datatype error"); if (geography && col_def->srid != 4326) throw runtime_error("SRID error"); ostringstream stream; stream.imbue(locale::classic()); stream << scientific; stream.precision(17); if (raster) stream << "ST_Envelope("; stream << sql_identifier(col); if (raster) stream << ")"; stream << " && "; if (geography) stream << "ST_GeogFromWKB(ST_AsBinary("; stream << "ST_SetSRID(ST_MakeBox2D(ST_Point(" << xmin << ", " << ymin << "), ST_Point(" << xmax << ", " << ymax << ")), " << col_def->srid << ")"; if (geography) stream << "))"; return stream.str(); } // dialect_postgres::