1108 |
1108 |
|
1109 |
1109 |
|
1110 |
1110 |
--
|
|
1111 |
-- Name: coordinates; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
|
1112 |
--
|
|
1113 |
|
|
1114 |
CREATE TABLE coordinates (
|
|
1115 |
coordinates_id integer NOT NULL,
|
|
1116 |
creator_id integer NOT NULL,
|
|
1117 |
latitude_deg double precision NOT NULL,
|
|
1118 |
longitude_deg double precision NOT NULL,
|
|
1119 |
verbatimlatitude text,
|
|
1120 |
verbatimlongitude text,
|
|
1121 |
verbatimcoordinates text,
|
|
1122 |
footprintgeometry_dwc text,
|
|
1123 |
coordsaccuracy_deg double precision
|
|
1124 |
);
|
|
1125 |
|
|
1126 |
|
|
1127 |
--
|
|
1128 |
-- Name: COLUMN coordinates.footprintgeometry_dwc; Type: COMMENT; Schema: public; Owner: -
|
|
1129 |
--
|
|
1130 |
|
|
1131 |
COMMENT ON COLUMN coordinates.footprintgeometry_dwc IS 'DwC''s footprintWKT field. "A Well-Known Text (WKT) representation of the shape (footprint, geometry) that defines the Location" (http://rs.tdwg.org/dwc/terms/#footprintWKT).';
|
|
1132 |
|
|
1133 |
|
|
1134 |
--
|
|
1135 |
-- Name: COLUMN coordinates.coordsaccuracy_deg; Type: COMMENT; Schema: public; Owner: -
|
|
1136 |
--
|
|
1137 |
|
|
1138 |
COMMENT ON COLUMN coordinates.coordsaccuracy_deg IS 'Accuracy of latitude/longitude or footprint geometry, in meters. This should generally be at least 1 m, which is the accuracy of the best GPSes.';
|
|
1139 |
|
|
1140 |
|
|
1141 |
--
|
1111 |
1142 |
-- Name: location; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
1112 |
1143 |
--
|
1113 |
1144 |
|
... | ... | |
1167 |
1198 |
|
1168 |
1199 |
|
1169 |
1200 |
--
|
1170 |
|
-- Name: locationcoords; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
1171 |
|
--
|
1172 |
|
|
1173 |
|
CREATE TABLE locationcoords (
|
1174 |
|
locationcoords_id integer NOT NULL,
|
1175 |
|
location_id integer NOT NULL,
|
1176 |
|
latitude_deg double precision,
|
1177 |
|
longitude_deg double precision,
|
1178 |
|
verbatimlatitude text,
|
1179 |
|
verbatimlongitude text,
|
1180 |
|
verbatimcoordinates text,
|
1181 |
|
footprintgeometry_dwc text,
|
1182 |
|
coordsaccuracy_deg double precision,
|
1183 |
|
identifier_id integer,
|
1184 |
|
determinationdate date,
|
1185 |
|
isoriginal boolean DEFAULT false NOT NULL,
|
1186 |
|
iscurrent boolean DEFAULT false NOT NULL,
|
1187 |
|
calculated boolean
|
1188 |
|
);
|
1189 |
|
|
1190 |
|
|
1191 |
|
--
|
1192 |
|
-- Name: COLUMN locationcoords.footprintgeometry_dwc; Type: COMMENT; Schema: public; Owner: -
|
1193 |
|
--
|
1194 |
|
|
1195 |
|
COMMENT ON COLUMN locationcoords.footprintgeometry_dwc IS 'DwC''s footprintWKT field. "A Well-Known Text (WKT) representation of the shape (footprint, geometry) that defines the Location" (http://rs.tdwg.org/dwc/terms/#footprintWKT).';
|
1196 |
|
|
1197 |
|
|
1198 |
|
--
|
1199 |
|
-- Name: COLUMN locationcoords.coordsaccuracy_deg; Type: COMMENT; Schema: public; Owner: -
|
1200 |
|
--
|
1201 |
|
|
1202 |
|
COMMENT ON COLUMN locationcoords.coordsaccuracy_deg IS 'Accuracy of latitude/longitude or footprint geometry, in meters. This should generally be at least 1 m, which is the accuracy of the best GPSes.';
|
1203 |
|
|
1204 |
|
|
1205 |
|
--
|
1206 |
1201 |
-- Name: locationevent; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
1207 |
1202 |
--
|
1208 |
1203 |
|
... | ... | |
1855 |
1850 |
--
|
1856 |
1851 |
|
1857 |
1852 |
CREATE VIEW analytical_db_view AS
|
1858 |
|
SELECT datasource.organizationname AS "institutionCode", place.country, place.stateprovince AS "stateProvince", place.county, locationcoords.latitude_deg AS "decimalLatitude", locationcoords.longitude_deg AS "decimalLongitude", location.sourceaccessioncode AS "plotName", location.elevation_m AS "elevationInMeters", _m2_to_ha(location.area_m2) AS "plotArea_ha", method.name AS "samplingProtocol", aggregateoccurrence.collectiondate AS "dateCollected", accepted_taxonverbatim.family, accepted_taxonverbatim.genus, ((accepted_taxonverbatim.genus || ' '::text) || accepted_taxonverbatim.specific_epithet) AS "speciesBinomial", COALESCE(accepted_taxonverbatim.taxonomicname, accepted_taxonverbatim.binomial) AS "scientificName", accepted_taxonverbatim.author AS "scientificNameAuthorship", NULLIF(array_to_string(ARRAY[accepted_taxonverbatim.taxonomicname, parsed_taxonverbatim.morphospecies], ' '::text), ''::text) AS "scientificNameWithMorphospecies", NULLIF(array_to_string(ARRAY[identifiedby.givenname, identifiedby.middlename, identifiedby.surname], ' '::text), ''::text) AS "identifiedBy", taxonoccurrence.growthform AS "growthForm", taxonoccurrence.iscultivated AS cultivated, taxonoccurrence.cultivatedbasis AS "cultivatedBasis", _fraction_to_percent(aggregateoccurrence.cover_fraction) AS "coverPercent", _m_to_cm(stemobservation.diameterbreastheight_m) AS "diameterBreastHeight_cm", stemobservation.height_m, stemobservation.tag, stemobservation.xposition_m AS "organismX_m", stemobservation.yposition_m AS "organismY_m", taxonoccurrence.verbatimcollectorname AS "recordedBy", plantobservation.collectionnumber AS "recordNumber" FROM (((((((((((((((((((party datasource JOIN location ON ((location.creator_id = datasource.party_id))) LEFT JOIN locationcoords USING (location_id)) LEFT JOIN locationplace USING (location_id)) LEFT JOIN place USING (place_id)) JOIN locationevent USING (location_id)) LEFT JOIN method USING (method_id)) JOIN taxonoccurrence USING (locationevent_id)) JOIN taxondetermination USING (taxonoccurrence_id)) LEFT JOIN party identifiedby ON ((identifiedby.party_id = taxondetermination.party_id))) JOIN taxonverbatim datasource_taxonverbatim USING (taxonverbatim_id)) JOIN taxonlabel datasource_taxonlabel USING (taxonlabel_id)) JOIN taxonlabel parsed_taxonlabel ON ((parsed_taxonlabel.taxonlabel_id = datasource_taxonlabel.matched_label_id))) LEFT JOIN taxonverbatim parsed_taxonverbatim ON ((parsed_taxonverbatim.taxonlabel_id = parsed_taxonlabel.taxonlabel_id))) JOIN taxonlabel accepted_taxonlabel ON ((accepted_taxonlabel.taxonlabel_id = datasource_taxonlabel.canon_label_id))) JOIN taxonverbatim accepted_taxonverbatim ON ((accepted_taxonverbatim.taxonlabel_id = accepted_taxonlabel.taxonlabel_id))) LEFT JOIN aggregateoccurrence USING (taxonoccurrence_id)) LEFT JOIN plantobservation USING (aggregateoccurrence_id)) LEFT JOIN stemobservation USING (plantobservation_id)) LEFT JOIN specimenreplicate USING (plantobservation_id)) WHERE ((datasource.creator_id = datasource.party_id) AND (NOT taxondetermination.isoriginal));
|
|
1853 |
SELECT datasource.organizationname AS "institutionCode", place.country, place.stateprovince AS "stateProvince", place.county, coordinates.latitude_deg AS "decimalLatitude", coordinates.longitude_deg AS "decimalLongitude", location.sourceaccessioncode AS "plotName", location.elevation_m AS "elevationInMeters", _m2_to_ha(location.area_m2) AS "plotArea_ha", method.name AS "samplingProtocol", aggregateoccurrence.collectiondate AS "dateCollected", accepted_taxonverbatim.family, accepted_taxonverbatim.genus, ((accepted_taxonverbatim.genus || ' '::text) || accepted_taxonverbatim.specific_epithet) AS "speciesBinomial", COALESCE(accepted_taxonverbatim.taxonomicname, accepted_taxonverbatim.binomial) AS "scientificName", accepted_taxonverbatim.author AS "scientificNameAuthorship", NULLIF(array_to_string(ARRAY[accepted_taxonverbatim.taxonomicname, parsed_taxonverbatim.morphospecies], ' '::text), ''::text) AS "scientificNameWithMorphospecies", NULLIF(array_to_string(ARRAY[identifiedby.givenname, identifiedby.middlename, identifiedby.surname], ' '::text), ''::text) AS "identifiedBy", taxonoccurrence.growthform AS "growthForm", taxonoccurrence.iscultivated AS cultivated, taxonoccurrence.cultivatedbasis AS "cultivatedBasis", _fraction_to_percent(aggregateoccurrence.cover_fraction) AS "coverPercent", _m_to_cm(stemobservation.diameterbreastheight_m) AS "diameterBreastHeight_cm", stemobservation.height_m, stemobservation.tag, stemobservation.xposition_m AS "organismX_m", stemobservation.yposition_m AS "organismY_m", taxonoccurrence.verbatimcollectorname AS "recordedBy", plantobservation.collectionnumber AS "recordNumber" FROM (((((((((((((((((((party datasource JOIN location ON ((location.creator_id = datasource.party_id))) LEFT JOIN locationplace USING (location_id)) LEFT JOIN place USING (place_id)) LEFT JOIN coordinates USING (coordinates_id)) JOIN locationevent USING (location_id)) LEFT JOIN method USING (method_id)) JOIN taxonoccurrence USING (locationevent_id)) JOIN taxondetermination USING (taxonoccurrence_id)) LEFT JOIN party identifiedby ON ((identifiedby.party_id = taxondetermination.party_id))) JOIN taxonverbatim datasource_taxonverbatim USING (taxonverbatim_id)) JOIN taxonlabel datasource_taxonlabel USING (taxonlabel_id)) JOIN taxonlabel parsed_taxonlabel ON ((parsed_taxonlabel.taxonlabel_id = datasource_taxonlabel.matched_label_id))) LEFT JOIN taxonverbatim parsed_taxonverbatim ON ((parsed_taxonverbatim.taxonlabel_id = parsed_taxonlabel.taxonlabel_id))) JOIN taxonlabel accepted_taxonlabel ON ((accepted_taxonlabel.taxonlabel_id = datasource_taxonlabel.canon_label_id))) JOIN taxonverbatim accepted_taxonverbatim ON ((accepted_taxonverbatim.taxonlabel_id = accepted_taxonlabel.taxonlabel_id))) LEFT JOIN aggregateoccurrence USING (taxonoccurrence_id)) LEFT JOIN plantobservation USING (aggregateoccurrence_id)) LEFT JOIN stemobservation USING (plantobservation_id)) LEFT JOIN specimenreplicate USING (plantobservation_id)) WHERE ((datasource.creator_id = datasource.party_id) AND (NOT taxondetermination.isoriginal));
|
1859 |
1854 |
|
1860 |
1855 |
|
1861 |
1856 |
--
|
... | ... | |
2174 |
2169 |
|
2175 |
2170 |
|
2176 |
2171 |
--
|
2177 |
|
-- Name: coordinates; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
2178 |
|
--
|
2179 |
|
|
2180 |
|
CREATE TABLE coordinates (
|
2181 |
|
coordinates_id integer NOT NULL,
|
2182 |
|
creator_id integer NOT NULL,
|
2183 |
|
latitude_deg double precision NOT NULL,
|
2184 |
|
longitude_deg double precision NOT NULL,
|
2185 |
|
verbatimlatitude text,
|
2186 |
|
verbatimlongitude text,
|
2187 |
|
verbatimcoordinates text,
|
2188 |
|
footprintgeometry_dwc text,
|
2189 |
|
coordsaccuracy_deg double precision
|
2190 |
|
);
|
2191 |
|
|
2192 |
|
|
2193 |
|
--
|
2194 |
|
-- Name: COLUMN coordinates.footprintgeometry_dwc; Type: COMMENT; Schema: public; Owner: -
|
2195 |
|
--
|
2196 |
|
|
2197 |
|
COMMENT ON COLUMN coordinates.footprintgeometry_dwc IS 'DwC''s footprintWKT field. "A Well-Known Text (WKT) representation of the shape (footprint, geometry) that defines the Location" (http://rs.tdwg.org/dwc/terms/#footprintWKT).';
|
2198 |
|
|
2199 |
|
|
2200 |
|
--
|
2201 |
|
-- Name: COLUMN coordinates.coordsaccuracy_deg; Type: COMMENT; Schema: public; Owner: -
|
2202 |
|
--
|
2203 |
|
|
2204 |
|
COMMENT ON COLUMN coordinates.coordsaccuracy_deg IS 'Accuracy of latitude/longitude or footprint geometry, in meters. This should generally be at least 1 m, which is the accuracy of the best GPSes.';
|
2205 |
|
|
2206 |
|
|
2207 |
|
--
|
2208 |
2172 |
-- Name: coordinates_coordinates_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
2209 |
2173 |
--
|
2210 |
2174 |
|
... | ... | |
2422 |
2386 |
|
2423 |
2387 |
|
2424 |
2388 |
--
|
|
2389 |
-- Name: locationcoords; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
|
2390 |
--
|
|
2391 |
|
|
2392 |
CREATE TABLE locationcoords (
|
|
2393 |
locationcoords_id integer NOT NULL,
|
|
2394 |
location_id integer NOT NULL,
|
|
2395 |
latitude_deg double precision,
|
|
2396 |
longitude_deg double precision,
|
|
2397 |
verbatimlatitude text,
|
|
2398 |
verbatimlongitude text,
|
|
2399 |
verbatimcoordinates text,
|
|
2400 |
footprintgeometry_dwc text,
|
|
2401 |
coordsaccuracy_deg double precision,
|
|
2402 |
identifier_id integer,
|
|
2403 |
determinationdate date,
|
|
2404 |
isoriginal boolean DEFAULT false NOT NULL,
|
|
2405 |
iscurrent boolean DEFAULT false NOT NULL,
|
|
2406 |
calculated boolean
|
|
2407 |
);
|
|
2408 |
|
|
2409 |
|
|
2410 |
--
|
|
2411 |
-- Name: COLUMN locationcoords.footprintgeometry_dwc; Type: COMMENT; Schema: public; Owner: -
|
|
2412 |
--
|
|
2413 |
|
|
2414 |
COMMENT ON COLUMN locationcoords.footprintgeometry_dwc IS 'DwC''s footprintWKT field. "A Well-Known Text (WKT) representation of the shape (footprint, geometry) that defines the Location" (http://rs.tdwg.org/dwc/terms/#footprintWKT).';
|
|
2415 |
|
|
2416 |
|
|
2417 |
--
|
|
2418 |
-- Name: COLUMN locationcoords.coordsaccuracy_deg; Type: COMMENT; Schema: public; Owner: -
|
|
2419 |
--
|
|
2420 |
|
|
2421 |
COMMENT ON COLUMN locationcoords.coordsaccuracy_deg IS 'Accuracy of latitude/longitude or footprint geometry, in meters. This should generally be at least 1 m, which is the accuracy of the best GPSes.';
|
|
2422 |
|
|
2423 |
|
|
2424 |
--
|
2425 |
2425 |
-- Name: locationcoords_locationcoords_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
2426 |
2426 |
--
|
2427 |
2427 |
|
schemas/vegbien.sql: analytical_db_view: Use new coordinates instead of locationcoords