44 b->
xmin = -DBL_MAX + 1;
45 b->
ymin = -DBL_MAX + 1;
46 b->
xmax = DBL_MAX - 1;
47 b->
ymax = DBL_MAX - 1;
75 if (xmin >= xmax || ymin >= ymax)
return false;
77 if ( fabs(xmin - DBL_MAX) < DBL_EPSILON
78 || fabs(ymin - DBL_MAX) < DBL_EPSILON
79 || fabs(xmax - DBL_MAX) < DBL_EPSILON
80 || fabs(ymax - DBL_MAX) < DBL_EPSILON)
return false;
97 bool honours_authority_axis_order_if_no_explicit_srs)
99 double xmin, ymin, xmax, ymax;
104 assert(o && bb && str);
130 ret =
ows_bbox_set(o, bb, xmin, ymin, xmax, ymax, srid);
138 ret =
ows_bbox_set(o, bb, xmin, ymin, xmax, ymax, srid);
162 assert(o && from && where && srs);
166 if (from->
size != where->
size)
return bb;
170 buffer_add_str(sql,
"SELECT ST_xmin(g.extent), ST_ymin(g.extent), ST_xmax(g.extent), ST_ymax(g.extent) FROM ");
171 buffer_add_str(sql,
"(SELECT ST_Extent(foo.the_geom) as extent FROM ( ");
174 for (ln_from = from->
first, ln_where = where->
first;
176 ln_from = ln_from->
next, ln_where = ln_where->
next) {
180 for (ln_geom = geom->
first ; ln_geom ; ln_geom = ln_geom->
next) {
204 if (PQresultStatus(res) != PGRES_TUPLES_OK || PQntuples(res) != 4) {
209 bb->
xmin = strtod(PQgetvalue(res, 0, 0), NULL);
210 bb->
ymin = strtod(PQgetvalue(res, 0, 1), NULL);
211 bb->
xmax = strtod(PQgetvalue(res, 0, 2), NULL);
212 bb->
ymax = strtod(PQgetvalue(res, 0, 3), NULL);
233 buffer_add_str(sql,
"SELECT xmin(g), ymin(g), xmax(g), ymax(g) FROM (SELECT ST_Transform(");
240 if (PQresultStatus(res) != PGRES_TUPLES_OK) {
245 bb->
xmin = strtod(PQgetvalue(res, 0, 0), NULL);
246 bb->
ymin = strtod(PQgetvalue(res, 0, 1), NULL);
247 bb->
xmax = strtod(PQgetvalue(res, 0, 2), NULL);
248 bb->
ymax = strtod(PQgetvalue(res, 0, 3), NULL);
287 double x1, y1, x2, y2;
289 assert(o && bbox && query);
PGresult * ows_psql_exec(ows *o, const char *sql)
void buffer_copy(buffer *dest, const buffer *src)
list * ows_psql_geometry_column(ows *o, buffer *layer_name)
void buffer_add_str(buffer *buf, const char *str)
bool ows_srs_set_from_srsname(ows *o, ows_srs *s, const char *srsname)
void ows_bbox_flush(const ows_bbox *b, FILE *output)
void buffer_add_double(buffer *buf, double f)
bool ows_srs_set_from_srid(ows *o, ows_srs *s, int srid)
void ows_srs_flush(ows_srs *c, FILE *output)
void buffer_free(buffer *buf)
void buffer_add_int(buffer *buf, int i)
bool ows_srs_set_geobbox(ows *o, ows_srs *s)
void ows_srs_free(ows_srs *c)
buffer * ows_psql_table_name(ows *o, buffer *layer_name)
list * list_explode(char separator, const buffer *value)
ows_srs * ows_srs_copy(ows_srs *d, ows_srs *s)
buffer * ows_psql_schema_name(ows *o, buffer *layer_name)
void ows_bbox_free(ows_bbox *b)
ows_bbox * ows_bbox_init()
bool ows_bbox_set_from_geobbox(ows *o, ows_bbox *bb, ows_geobbox *geo)
ows_bbox * ows_bbox_boundaries(ows *o, list *from, list *where, ows_srs *srs)
bool ows_bbox_transform(ows *o, ows_bbox *bb, int srid)
void ows_bbox_to_query(ows *o, ows_bbox *bbox, buffer *query)
bool ows_bbox_set_from_str(ows *o, ows_bbox *bb, const char *str, int srid, bool honours_authority_axis_order_if_no_explicit_srs)
bool ows_bbox_set(ows *o, ows_bbox *b, double xmin, double ymin, double xmax, double ymax, int srid)
char * buf
size to next realloc
bool honours_authority_axis_order
bool is_axis_order_gis_friendly