I have this query:
select sum(way_area) from planet_osm_polygon
where building<>'no' and building<>''
and way && st_transform(
st_setsrid(st_makebox2d(
st_point(2.2852565067385426, 50.990981849954764),
st_point(2.2861549793351283, 50.990083377358175))
,4326)
,3857);
I would like to change it so that it only considers the area of the building that is in the zone, instead of the whole building. I suppose I should use st_intersects but how do I use it with my box to only have the little bits counted?
I tried this query but it gives me the same result as the first one (which is not what I need):
select sum(way_area) from planet_osm_polygon where building<>'no' and building<>'' and
st_intersects(
st_transform(st_setsrid(st_makebox2d(st_point(2.2852565067385426, 50.990981849954764), st_point(2.2861549793351283, 50.990083377358175)),4326),3857)
,way);
Additional info that may be useful: the way_area column contains the total surface on ground of a polygon, and the way column contains the geometry.