Project

General

Profile

« Previous | Next » 

Revision 5862

schemas/vegbien.sql: analytical_db_view: Use new coordinates instead of locationcoords

View differences:

schemas/vegbien.my.sql
603 603

  
604 604

  
605 605
--
606
-- Name: coordinates; Type: TABLE; Schema: public; Owner: -; Tablespace: 
607
--
608

  
609
CREATE TABLE coordinates (
610
    coordinates_id int(11) NOT NULL,
611
    creator_id int(11) NOT NULL,
612
    latitude_deg double precision NOT NULL,
613
    longitude_deg double precision NOT NULL,
614
    verbatimlatitude text,
615
    verbatimlongitude text,
616
    verbatimcoordinates text,
617
    footprintgeometry_dwc text,
618
    coordsaccuracy_deg double precision
619
);
620

  
621

  
622
--
623
-- Name: COLUMN coordinates.footprintgeometry_dwc; Type: COMMENT; Schema: public; Owner: -
624
--
625

  
626

  
627

  
628

  
629
--
630
-- Name: COLUMN coordinates.coordsaccuracy_deg; Type: COMMENT; Schema: public; Owner: -
631
--
632

  
633

  
634

  
635

  
636
--
606 637
-- Name: location; Type: TABLE; Schema: public; Owner: -; Tablespace: 
607 638
--
608 639

  
......
661 692

  
662 693

  
663 694
--
664
-- Name: locationcoords; Type: TABLE; Schema: public; Owner: -; Tablespace: 
665
--
666

  
667
CREATE TABLE locationcoords (
668
    locationcoords_id int(11) NOT NULL,
669
    location_id int(11) NOT NULL,
670
    latitude_deg double precision,
671
    longitude_deg double precision,
672
    verbatimlatitude text,
673
    verbatimlongitude text,
674
    verbatimcoordinates text,
675
    footprintgeometry_dwc text,
676
    coordsaccuracy_deg double precision,
677
    identifier_id int(11),
678
    determinationdate date,
679
    isoriginal int(1) DEFAULT false NOT NULL,
680
    iscurrent int(1) DEFAULT false NOT NULL,
681
    calculated int(1)
682
);
683

  
684

  
685
--
686
-- Name: COLUMN locationcoords.footprintgeometry_dwc; Type: COMMENT; Schema: public; Owner: -
687
--
688

  
689

  
690

  
691

  
692
--
693
-- Name: COLUMN locationcoords.coordsaccuracy_deg; Type: COMMENT; Schema: public; Owner: -
694
--
695

  
696

  
697

  
698

  
699
--
700 695
-- Name: locationevent; Type: TABLE; Schema: public; Owner: -; Tablespace: 
701 696
--
702 697

  
......
1585 1580

  
1586 1581

  
1587 1582
--
1588
-- Name: coordinates; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1589
--
1590

  
1591
CREATE TABLE coordinates (
1592
    coordinates_id int(11) NOT NULL,
1593
    creator_id int(11) NOT NULL,
1594
    latitude_deg double precision NOT NULL,
1595
    longitude_deg double precision NOT NULL,
1596
    verbatimlatitude text,
1597
    verbatimlongitude text,
1598
    verbatimcoordinates text,
1599
    footprintgeometry_dwc text,
1600
    coordsaccuracy_deg double precision
1601
);
1602

  
1603

  
1604
--
1605
-- Name: COLUMN coordinates.footprintgeometry_dwc; Type: COMMENT; Schema: public; Owner: -
1606
--
1607

  
1608

  
1609

  
1610

  
1611
--
1612
-- Name: COLUMN coordinates.coordsaccuracy_deg; Type: COMMENT; Schema: public; Owner: -
1613
--
1614

  
1615

  
1616

  
1617

  
1618
--
1619 1583
-- Name: coordinates_coordinates_id_seq; Type: SEQUENCE; Schema: public; Owner: -
1620 1584
--
1621 1585

  
......
1793 1757

  
1794 1758

  
1795 1759
--
1760
-- Name: locationcoords; Type: TABLE; Schema: public; Owner: -; Tablespace: 
1761
--
1762

  
1763
CREATE TABLE locationcoords (
1764
    locationcoords_id int(11) NOT NULL,
1765
    location_id int(11) NOT NULL,
1766
    latitude_deg double precision,
1767
    longitude_deg double precision,
1768
    verbatimlatitude text,
1769
    verbatimlongitude text,
1770
    verbatimcoordinates text,
1771
    footprintgeometry_dwc text,
1772
    coordsaccuracy_deg double precision,
1773
    identifier_id int(11),
1774
    determinationdate date,
1775
    isoriginal int(1) DEFAULT false NOT NULL,
1776
    iscurrent int(1) DEFAULT false NOT NULL,
1777
    calculated int(1)
1778
);
1779

  
1780

  
1781
--
1782
-- Name: COLUMN locationcoords.footprintgeometry_dwc; Type: COMMENT; Schema: public; Owner: -
1783
--
1784

  
1785

  
1786

  
1787

  
1788
--
1789
-- Name: COLUMN locationcoords.coordsaccuracy_deg; Type: COMMENT; Schema: public; Owner: -
1790
--
1791

  
1792

  
1793

  
1794

  
1795
--
1796 1796
-- Name: locationcoords_locationcoords_id_seq; Type: SEQUENCE; Schema: public; Owner: -
1797 1797
--
1798 1798

  
schemas/vegbien.sql
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

  

Also available in: Unified diff