Database Reference
In-Depth Information
Constructing and serving buildings 2.5
D
Inthe Generating detailed building footprints from LiDAR recipein Chapter4 , Working
with Vector Data - Advanced Recipes ,weexploredtheautomaticgenerationofbuild-
ingfootprintsusingLiDARdata.Whatwewereattemptingtodowascreate2Ddata
from 3D data. In this recipe, we attempt the opposite, in a sense. We start with 2D
polygonsofbuildingfootprintsandfeedthemintoafunctionthatextrudesthemas3D
polygons.
Getting ready
Foruseinthisproject,wewillextrudeabuildingfootprintofourownmaking.Letus
quickly create a table with asingle building footprint, for testing purposes, as follows:
CREATE TABLE chp07.simple_building AS
SELECT 1 AS gid,
ST_MakePolygon(ST_GeomFromText('LINESTRING(0 0,2
0,2 1, 1 1, 1 2, 0 2, 0 0)')) AS the_geom;
Letusaddafunctionfromthe Improving ST_Polygonize recipein Chapter4 , Working
with Vector Data - Advanced Recipes , that converts geometry collections to multi-
polygons and add it to this schema. The converted function is as shown below:
CREATE OR REPLACE FUNCTION
chp07.polygonize_to_multi (geometry)
RETURNS geometry AS $$
WITH polygonized AS (
SELECT ST_Polygonize($1) AS the_geom
),
dumped AS (
SELECT (ST_Dump(the_geom)).geom AS the_geom
FROM
polygonized
Search WWH ::




Custom Search