The Queries
$query="select a.block_number, a.building_id, b.title, b.narrative, b.iconic_image_id, c.access_url ,b.caption from building_forms a ,the_histories b, images c where a.building_id=".$building_id." and b.temporal_object_id=a.building_id and b.iconic_image_id=c.id";
$rs = pg_query($con, $query) or die("Cannot execute query: $query\n");
$rows = pg_fetch_all($rs);
pg_close($con);
--------------------------------------------------------------------------
$query = "select a.height, to_char(a.default_date, 'YYYY-MM-DD') from cesium_entities a, temporal_objects b where b.id=a.temporalobject_ptr_id and a.entity_type=0 and trim(both ' ' from b.block_number)='" . $bn . "'";
-------------------------------------------------------------------------------------------------------------------
$query1 = 'SELECT b.block_number, a.building_id, c.value, c.is_valid, d.value, d.is_valid, a.points,e.ge_latitude,e.ge_longitude FROM saintlouisdev.geo_footprints a, saintlouisdev.temporal_objects b, saintlouisdev.vc_dates c, saintlouisdev.vc_dates d,CesiumLatLong e WHERE ' . $the_clause;
$query2 = ' AND a.temporalobject_ptr_id=b.id AND b.start_date_id=c.id AND b.end_date_id=d.id AND e.building_id=a.building_id;';
$query = $query1 . $query2;
--------------------------------------------------------------------------------------------------------
$the_clause = 'b.block_number=' . "'" . $bns[0] . "' ";
for ($ib = 1; $ib < $block_count; $ib++) {
$the_clause = $the_clause . 'or b.block_number=' . "'" . $bns[$ib] . "' ";
}
$the_clause = ' (' . $the_clause . ') ';
$query1 = 'SELECT b.block_number, a.building_id, c.value, c.is_valid, d.value, d.is_valid, a.points,e.ge_latitude,e.ge_longitude FROM saintlouisdev.geo_footprints a, saintlouisdev.temporal_objects b, saintlouisdev.vc_dates c, saintlouisdev.vc_dates d,CesiumLatLong e WHERE ' . $the_clause;
$query2 = ' AND a.temporalobject_ptr_id=b.id AND b.start_date_id=c.id AND b.end_date_id=d.id AND e.building_id=a.building_id;';
$query = $query1 . $query2;
---------------------------------------------------------------------------------------------------
The Tables
building_forms a ,the_histories b, images c
cesium_entities a, temporal_objects b
saintlouisdev.geo_footprints a, saintlouisdev.temporal_objects b, saintlouisdev.vc_dates c, saintlouisdev.vc_dates d,CesiumLatLong e
-- Table: saintlouisdev.building_forms
-- DROP TABLE saintlouisdev.building_forms;
CREATE TABLE saintlouisdev.building_forms
(
id integer NOT NULL DEFAULT nextval('building_forms_id_seq'::regclass),
author_name character varying(50) COLLATE pg_catalog."default" NOT NULL,
block_number character varying(10) COLLATE pg_catalog."default" NOT NULL,
data_source character varying(50) COLLATE pg_catalog."default" NOT NULL,
start_date date NOT NULL,
start_valid boolean NOT NULL,
end_date date NOT NULL,
end_valid boolean NOT NULL,
low_address integer NOT NULL,
high_address integer NOT NULL,
streetname character varying(50) COLLATE pg_catalog."default" NOT NULL,
stories integer NOT NULL,
height double precision NOT NULL,
depth double precision NOT NULL,
front_setback double precision NOT NULL,
right_setback double precision NOT NULL,
left_setback double precision NOT NULL,
building_use character varying(50) COLLATE pg_catalog."default" NOT NULL,
building_type character varying(50) COLLATE pg_catalog."default" NOT NULL,
building_name character varying(50) COLLATE pg_catalog."default" NOT NULL,
building_url character varying(200) COLLATE pg_catalog."default" NOT NULL,
building_style character varying(50) COLLATE pg_catalog."default" NOT NULL,
texture_type character varying(50) COLLATE pg_catalog."default" NOT NULL,
model_file character varying(50) COLLATE pg_catalog."default" NOT NULL,
bays integer NOT NULL,
repetition integer NOT NULL,
pattern character varying(31) COLLATE pg_catalog."default" NOT NULL,
corners integer NOT NULL,
roof_type integer NOT NULL,
architect character varying(50) COLLATE pg_catalog."default" NOT NULL,
comments text COLLATE pg_catalog."default" NOT NULL,
description text COLLATE pg_catalog."default" NOT NULL,
building_id integer NOT NULL,
created_at date NOT NULL,
CONSTRAINT building_forms_pkey PRIMARY KEY (id),
CONSTRAINT building_forms_building_id_fkey FOREIGN KEY (building_id)
REFERENCES saintlouisdev.buildings (temporalobject_ptr_id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
DEFERRABLE INITIALLY DEFERRED
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE saintlouisdev.building_forms
OWNER to saintlouisdev;
-- Index: building_forms_building_id
-- DROP INDEX saintlouisdev.building_forms_building_id;
CREATE INDEX building_forms_building_id
ON saintlouisdev.building_forms USING btree
(building_id)
TABLESPACE pg_default;
---------------------------------------------------------------------
-- Table: saintlouisdev.the_histories
-- DROP TABLE saintlouisdev.the_histories;
CREATE TABLE saintlouisdev.the_histories
(
id integer NOT NULL DEFAULT nextval('the_histories_id_seq'::regclass),
title character varying(50) COLLATE pg_catalog."default",
start_date date,
end_date date,
keywords text COLLATE pg_catalog."default",
narrative text COLLATE pg_catalog."default",
iconic_image_id integer,
caption text COLLATE pg_catalog."default",
source character varying(50) COLLATE pg_catalog."default",
name character varying(50) COLLATE pg_catalog."default",
temporal_object_id integer NOT NULL,
CONSTRAINT the_histories_pkey PRIMARY KEY (id),
CONSTRAINT the_histories_temporal_object_id_fkey FOREIGN KEY (temporal_object_id)
REFERENCES saintlouisdev.temporal_objects (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
DEFERRABLE INITIALLY DEFERRED
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE saintlouisdev.the_histories
OWNER to saintlouisdev;
-- Index: the_histories_iconic_image_id
-- DROP INDEX saintlouisdev.the_histories_iconic_image_id;
CREATE INDEX the_histories_iconic_image_id
ON saintlouisdev.the_histories USING btree
(iconic_image_id)
TABLESPACE pg_default;
-- Index: the_histories_temporal_object_id
-- DROP INDEX saintlouisdev.the_histories_temporal_object_id;
CREATE INDEX the_histories_temporal_object_id
ON saintlouisdev.the_histories USING btree
(temporal_object_id)
TABLESPACE pg_default;
-------------------------------------------------------------------------
-- Table: saintlouisdev.images
-- DROP TABLE saintlouisdev.images;
CREATE TABLE saintlouisdev.images
(
id integer NOT NULL DEFAULT nextval('images_id_seq1'::regclass),
indentifier_mdi character varying(50) COLLATE pg_catalog."default" NOT NULL,
title text COLLATE pg_catalog."default" NOT NULL,
title_alternative text COLLATE pg_catalog."default",
creator text COLLATE pg_catalog."default",
contributor character varying(50) COLLATE pg_catalog."default",
coverage text COLLATE pg_catalog."default",
description text COLLATE pg_catalog."default",
subject text COLLATE pg_catalog."default",
date date,
type character varying(50) COLLATE pg_catalog."default",
relation text COLLATE pg_catalog."default",
source text COLLATE pg_catalog."default",
rights text COLLATE pg_catalog."default",
publisher character varying(50) COLLATE pg_catalog."default",
language character varying(50) COLLATE pg_catalog."default",
access_url text COLLATE pg_catalog."default",
thumbnail_url text COLLATE pg_catalog."default",
access_file_size character varying(50) COLLATE pg_catalog."default",
CONSTRAINT images_pkey1 PRIMARY KEY (id)
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE saintlouisdev.images
OWNER to saintlouisdev;
---------------------------------------------------------
-- Table: saintlouisdev.cesium_entities
-- DROP TABLE saintlouisdev.cesium_entities;
CREATE TABLE saintlouisdev.cesium_entities
(
temporalobject_ptr_id integer NOT NULL,
entity_id integer NOT NULL DEFAULT nextval('cesium_entity_entity_id_seq'::regclass),
entity_type integer NOT NULL,
entity_reference character varying(50) COLLATE pg_catalog."default" NOT NULL,
height double precision NOT NULL,
entity_name character varying(50) COLLATE pg_catalog."default",
text character varying(600) COLLATE pg_catalog."default",
info_box_visibility boolean,
default_date date,
CONSTRAINT cesium_entity_pkey PRIMARY KEY (entity_id),
CONSTRAINT cesium_entity_temporalobject_ptr_id_fkey FOREIGN KEY (temporalobject_ptr_id)
REFERENCES saintlouisdev.temporal_objects (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE saintlouisdev.cesium_entities
OWNER to saintlouisdev;
-----------------------------------------------------------------------------
-- Table: saintlouisdev.temporal_objects
-- DROP TABLE saintlouisdev.temporal_objects;
CREATE TABLE saintlouisdev.temporal_objects
(
id integer NOT NULL DEFAULT nextval('temporal_objects_id_seq'::regclass),
block_number character varying(10) COLLATE pg_catalog."default",
object_type_id integer,
description text COLLATE pg_catalog."default",
vet_flag boolean,
start_date_id integer,
end_date_id integer,
CONSTRAINT temporal_objects_pkey PRIMARY KEY (id),
CONSTRAINT object_type_id_refs_id_316b80df FOREIGN KEY (object_type_id)
REFERENCES saintlouisdev.object_types (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
DEFERRABLE INITIALLY DEFERRED,
CONSTRAINT temporal_objects_end_date_id_fkey FOREIGN KEY (end_date_id)
REFERENCES saintlouisdev.vc_dates (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
DEFERRABLE INITIALLY DEFERRED,
CONSTRAINT temporal_objects_start_date_id_fkey FOREIGN KEY (start_date_id)
REFERENCES saintlouisdev.vc_dates (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
DEFERRABLE INITIALLY DEFERRED
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE saintlouisdev.temporal_objects
OWNER to saintlouisdev;
-- Index: temporal_objects_end_date_id
-- DROP INDEX saintlouisdev.temporal_objects_end_date_id;
CREATE INDEX temporal_objects_end_date_id
ON saintlouisdev.temporal_objects USING btree
(end_date_id)
TABLESPACE pg_default;
-- Index: temporal_objects_object_type_id
-- DROP INDEX saintlouisdev.temporal_objects_object_type_id;
CREATE INDEX temporal_objects_object_type_id
ON saintlouisdev.temporal_objects USING btree
(object_type_id)
TABLESPACE pg_default;
-- Index: temporal_objects_start_date_id
-- DROP INDEX saintlouisdev.temporal_objects_start_date_id;
CREATE INDEX temporal_objects_start_date_id
ON saintlouisdev.temporal_objects USING btree
(start_date_id)
TABLESPACE pg_default;
----------------------------------------------------------------
-- Table: saintlouisdev.geo_footprints<./font>
-- DROP TABLE saintlouisdev.geo_footprints;
CREATE TABLE saintlouisdev.geo_footprints
(
temporalobject_ptr_id integer NOT NULL,
building_id integer NOT NULL,
stories integer,
height double precision,
first_floor_height double precision,
top_floor_height double precision,
pattern character varying(20) COLLATE pg_catalog."default",
repetition integer,
bay_width double precision,
corners integer,
points text COLLATE pg_catalog."default" NOT NULL,
roof_type integer,
footprint_type integer,
texture_type integer,
elevation double precision,
source character varying(20) COLLATE pg_catalog."default",
front_texture_id integer,
wall_texture_id integer,
foundation_texture_id integer,
roof_texture_id integer,
CONSTRAINT geo_footprints_pkey PRIMARY KEY (temporalobject_ptr_id),
CONSTRAINT geo_footprints_building_id_fkey FOREIGN KEY (building_id)
REFERENCES saintlouisdev.buildings (temporalobject_ptr_id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
DEFERRABLE INITIALLY DEFERRED,
CONSTRAINT geo_footprints_foundation_texture_id_fkey FOREIGN KEY (foundation_texture_id)
REFERENCES saintlouisdev.textures (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
DEFERRABLE INITIALLY DEFERRED,
CONSTRAINT geo_footprints_front_texture_id_fkey FOREIGN KEY (front_texture_id)
REFERENCES saintlouisdev.textures (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
DEFERRABLE INITIALLY DEFERRED,
CONSTRAINT geo_footprints_roof_texture_id_fkey FOREIGN KEY (roof_texture_id)
REFERENCES saintlouisdev.textures (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
DEFERRABLE INITIALLY DEFERRED,
CONSTRAINT geo_footprints_temporalobject_ptr_id_fkey FOREIGN KEY (temporalobject_ptr_id)
REFERENCES saintlouisdev.temporal_objects (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
DEFERRABLE INITIALLY DEFERRED,
CONSTRAINT geo_footprints_wall_texture_id_fkey FOREIGN KEY (wall_texture_id)
REFERENCES saintlouisdev.textures (id) MATCH SIMPLE
ON UPDATE NO ACTION
ON DELETE NO ACTION
DEFERRABLE INITIALLY DEFERRED
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE saintlouisdev.geo_footprints
OWNER to saintlouisdev;
-- Index: geo_footprints_building_id
-- DROP INDEX saintlouisdev.geo_footprints_building_id;
CREATE INDEX geo_footprints_building_id
ON saintlouisdev.geo_footprints USING btree
(building_id)
TABLESPACE pg_default;
-------------------------------------------------------------------------------------------------
-- Table: saintlouisdev.vc_dates
-- DROP TABLE saintlouisdev.vc_dates;
CREATE TABLE saintlouisdev.vc_dates
(
id integer NOT NULL DEFAULT nextval('vc_dates_id_seq'::regclass),
value date NOT NULL,
is_valid boolean,
flag character varying(10) COLLATE pg_catalog."default",
CONSTRAINT vc_dates_pkey PRIMARY KEY (id)
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE saintlouisdev.vc_dates
OWNER to saintlouisdev;
----------------------------------------------------------
-- Table: saintlouisdev.cesiumlatlong
-- DROP TABLE saintlouisdev.cesiumlatlong;
CREATE TABLE saintlouisdev.cesiumlatlong
(
building_id integer NOT NULL,
ge_latitude double precision,
ge_longitude double precision,
CONSTRAINT cesiumlatlong_pkey PRIMARY KEY (building_id)
)
WITH (
OIDS = FALSE
)
TABLESPACE pg_default;
ALTER TABLE saintlouisdev.cesiumlatlong
OWNER to saintlouisdev;