2442 |
2442 |
|
2443 |
2443 |
|
2444 |
2444 |
--
|
|
2445 |
-- Name: stratum; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
|
2446 |
--
|
|
2447 |
|
|
2448 |
CREATE TABLE stratum (
|
|
2449 |
stratum_id integer NOT NULL,
|
|
2450 |
source_id integer NOT NULL,
|
|
2451 |
stratumname text NOT NULL,
|
|
2452 |
stratumheight double precision,
|
|
2453 |
stratumbase double precision,
|
|
2454 |
stratumcover double precision,
|
|
2455 |
area double precision,
|
|
2456 |
method_id integer
|
|
2457 |
);
|
|
2458 |
|
|
2459 |
|
|
2460 |
--
|
|
2461 |
-- Name: plot.**; Type: VIEW; Schema: public; Owner: -
|
|
2462 |
--
|
|
2463 |
|
|
2464 |
CREATE VIEW "plot.**" AS
|
|
2465 |
SELECT source.shortname AS datasource, COALESCE(geoscrub_output."acceptedCountry", place.country) AS country, COALESCE(geoscrub_output."acceptedStateProvince", place.stateprovince) AS "stateProvince", COALESCE(geoscrub_output."acceptedCounty", place.county) AS county, location.locationnarrative AS locality, CASE WHEN (coordinates.latitude_deg IS NOT NULL) THEN coordinates.latitude_deg ELSE county_centroids.latitude END AS "decimalLatitude", CASE WHEN (coordinates.latitude_deg IS NOT NULL) THEN coordinates.longitude_deg ELSE county_centroids.longitude END AS "decimalLongitude", CASE WHEN (coordinates.latitude_deg IS NOT NULL) THEN coordinates.coordsaccuracy_m ELSE _km_to_m(county_centroids.error_km) END AS "coordinateUncertaintyInMeters", CASE WHEN (coordinates.latitude_deg IS NOT NULL) THEN 'source data'::coordinatesource WHEN (county_centroids.row_num IS NOT NULL) THEN 'georeferencing'::coordinatesource ELSE NULL::coordinatesource END AS "coordinateSource_bien", CASE WHEN (coordinates.latitude_deg IS NOT NULL) THEN NULL::text WHEN (county_centroids.row_num IS NOT NULL) THEN 'county centroid'::text ELSE NULL::text END AS "georeferenceProtocol_bien", (geoscrub_output.geovalid)::integer AS geovalid_bien, ("newWorldCountries"."isNewWorld")::integer AS "isNewWorld_bien", COALESCE(project.sourceaccessioncode, project.projectname) AS "projectID", COALESCE(location.sourceaccessioncode, NULLIF(pg_catalog.concat_ws('; '::text, COALESCE(parent_location.sourceaccessioncode, parent_location.authorlocationcode), location.authorlocationcode), ''::text)) AS "locationID", COALESCE(parent_location.authorlocationcode, location.authorlocationcode) AS "locationName", CASE WHEN (parent_location.location_id IS NOT NULL) THEN location.authorlocationcode ELSE NULL::text END AS subplot, location.iscultivated AS location__cultivated__bien, locationevent.locationevent_id AS locationevent__pkey, COALESCE(locationevent.obsstartdate, parent_event.obsstartdate) AS "eventDate", COALESCE(location.elevation_m, parent_location.elevation_m) AS "elevationInMeters", _m2_to_ha(COALESCE(location.area_m2, parent_location.area_m2)) AS "plotArea_ha", method.name AS "samplingProtocol", COALESCE(locationevent.temperature_c, parent_event.temperature_c) AS "temperature_C", COALESCE(locationevent.precipitation_m, parent_event.precipitation_m) AS precipitation_m, stratum.stratumname AS stratum__name, COALESCE(locationevent__communities__array(locationevent.locationevent_id), locationevent__communities__array(parent_event.locationevent_id)) AS communities, COALESCE(locationevent__contributors__array(locationevent.locationevent_id), locationevent__contributors__array(parent_event.locationevent_id)) AS plot__collectors FROM ((((((((((((((source JOIN location USING (source_id)) LEFT JOIN locationevent USING (location_id)) LEFT JOIN location parent_location ON ((parent_location.location_id = location.parent_id))) LEFT JOIN locationplace ON ((locationplace.location_id = COALESCE(parent_location.location_id, location.location_id)))) LEFT JOIN place USING (place_id)) LEFT JOIN coordinates USING (coordinates_id)) LEFT JOIN geoscrub.geoscrub_output ON ((((((ARRAY[geoscrub_output."decimalLatitude"] = ARRAY[coordinates.latitude_deg]) AND (ARRAY[geoscrub_output."decimalLongitude"] = ARRAY[coordinates.longitude_deg])) AND (ARRAY[geoscrub_output.country] = ARRAY[place.country])) AND (ARRAY[geoscrub_output."stateProvince"] = ARRAY[place.stateprovince])) AND (ARRAY[geoscrub_output.county] = ARRAY[place.county])))) LEFT JOIN "newWorld".iso_code_gadm ON ((iso_code_gadm."*GADM country" = COALESCE(geoscrub_output."acceptedCountry", place.country)))) LEFT JOIN "newWorld"."newWorldCountries" ON (("newWorldCountries"."*isoCode" = iso_code_gadm."*2-digit iso code"))) LEFT JOIN geoscrub.county_centroids ON ((((place.country = 'United States'::text) AND (county_centroids.state = COALESCE(geoscrub_output."acceptedStateProvince", place.stateprovince))) AND (county_centroids.county = COALESCE(geoscrub_output."acceptedCounty", place.county))))) LEFT JOIN locationevent parent_event ON ((parent_event.locationevent_id = locationevent.parent_id))) LEFT JOIN project ON ((project.project_id = COALESCE(locationevent.project_id, parent_event.project_id)))) LEFT JOIN stratum ON ((stratum.stratum_id = COALESCE(locationevent.stratum_id, parent_event.stratum_id)))) LEFT JOIN method ON ((method.method_id = COALESCE(locationevent.method_id, parent_event.method_id))));
|
|
2466 |
|
|
2467 |
|
|
2468 |
--
|
2445 |
2469 |
-- Name: sourcelist; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
2446 |
2470 |
--
|
2447 |
2471 |
|
... | ... | |
2533 |
2557 |
|
2534 |
2558 |
|
2535 |
2559 |
--
|
2536 |
|
-- Name: stratum; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
2537 |
|
--
|
2538 |
|
|
2539 |
|
CREATE TABLE stratum (
|
2540 |
|
stratum_id integer NOT NULL,
|
2541 |
|
source_id integer NOT NULL,
|
2542 |
|
stratumname text NOT NULL,
|
2543 |
|
stratumheight double precision,
|
2544 |
|
stratumbase double precision,
|
2545 |
|
stratumcover double precision,
|
2546 |
|
area double precision,
|
2547 |
|
method_id integer
|
2548 |
|
);
|
2549 |
|
|
2550 |
|
|
2551 |
|
--
|
2552 |
2560 |
-- Name: taxondetermination; Type: TABLE; Schema: public; Owner: -; Tablespace:
|
2553 |
2561 |
--
|
2554 |
2562 |
|
... | ... | |
2731 |
2739 |
--
|
2732 |
2740 |
|
2733 |
2741 |
CREATE VIEW analytical_stem_view AS
|
2734 |
|
SELECT source.shortname AS datasource, COALESCE(geoscrub_output."acceptedCountry", place.country) AS country, COALESCE(geoscrub_output."acceptedStateProvince", place.stateprovince) AS "stateProvince", COALESCE(geoscrub_output."acceptedCounty", place.county) AS county, location.locationnarrative AS locality, CASE WHEN (coordinates.latitude_deg IS NOT NULL) THEN coordinates.latitude_deg ELSE county_centroids.latitude END AS "decimalLatitude", CASE WHEN (coordinates.latitude_deg IS NOT NULL) THEN coordinates.longitude_deg ELSE county_centroids.longitude END AS "decimalLongitude", CASE WHEN (coordinates.latitude_deg IS NOT NULL) THEN coordinates.coordsaccuracy_m ELSE _km_to_m(county_centroids.error_km) END AS "coordinateUncertaintyInMeters", CASE WHEN (coordinates.latitude_deg IS NOT NULL) THEN 'source data'::coordinatesource WHEN (county_centroids.row_num IS NOT NULL) THEN 'georeferencing'::coordinatesource ELSE NULL::coordinatesource END AS "coordinateSource_bien", CASE WHEN (coordinates.latitude_deg IS NOT NULL) THEN NULL::text WHEN (county_centroids.row_num IS NOT NULL) THEN 'county centroid'::text ELSE NULL::text END AS "georeferenceProtocol_bien", (geoscrub_output.geovalid)::integer AS geovalid_bien, ("newWorldCountries"."isNewWorld")::integer AS "isNewWorld_bien", COALESCE(project.sourceaccessioncode, project.projectname) AS "projectID", COALESCE(location.sourceaccessioncode, NULLIF(pg_catalog.concat_ws('; '::text, COALESCE(parent_location.sourceaccessioncode, parent_location.authorlocationcode), location.authorlocationcode), ''::text)) AS "locationID", COALESCE(parent_location.authorlocationcode, location.authorlocationcode) AS "locationName", CASE WHEN (parent_location.location_id IS NOT NULL) THEN location.authorlocationcode ELSE NULL::text END AS subplot, location.iscultivated AS location__cultivated__bien, locationevent.locationevent_id AS locationevent__pkey, COALESCE(locationevent.obsstartdate, parent_event.obsstartdate) AS "eventDate", COALESCE(location.elevation_m, parent_location.elevation_m) AS "elevationInMeters", _m2_to_ha(COALESCE(location.area_m2, parent_location.area_m2)) AS "plotArea_ha", method.name AS "samplingProtocol", COALESCE(locationevent.temperature_c, parent_event.temperature_c) AS "temperature_C", COALESCE(locationevent.precipitation_m, parent_event.precipitation_m) AS precipitation_m, stratum.stratumname AS stratum__name, COALESCE(locationevent__communities__array(locationevent.locationevent_id), locationevent__communities__array(parent_event.locationevent_id)) AS communities, COALESCE(locationevent__contributors__array(locationevent.locationevent_id), locationevent__contributors__array(parent_event.locationevent_id)) AS plot__collectors, sourcelist.name AS "specimenHolderInstitutions", specimenreplicate.collectioncode_dwc AS collection, specimenreplicate.catalognumber_dwc AS "accessionNumber", specimenreplicate.sourceaccessioncode AS "occurrenceID", collector.fullname AS "recordedBy", plantobservation.authorplantcode AS "recordNumber", COALESCE(aggregateoccurrence.collectiondate, locationevent.obsstartdate, parent_event.obsstartdate) AS "dateCollected", taxonverbatim.family AS family_verbatim, COALESCE(taxonverbatim.taxonomicname, NULLIF(pg_catalog.concat_ws(' '::text, taxonverbatim.taxonname, taxonverbatim.author), ''::text), taxonlabel.taxonomicname) AS "scientificName_verbatim", identifiedby.fullname AS "identifiedBy", taxondetermination.determinationdate AS "dateIdentified", taxondetermination.notes AS "identificationRemarks", "ScrubbedTaxon"."matchedFamily" AS family_matched, "ScrubbedTaxon"."matchedTaxonName" AS "taxonName_matched", "ScrubbedTaxon"."matchedScientificNameAuthorship" AS "scientificNameAuthorship_matched", family_higher_plant_group.higher_plant_group AS "higherPlantGroup_bien", "ScrubbedTaxon"."acceptedFamily" AS family, "ScrubbedTaxon"."acceptedGenus" AS genus, COALESCE(COALESCE(NULLIF(pg_catalog.concat_ws(' '::text, COALESCE("ScrubbedTaxon"."acceptedGenus", "ScrubbedTaxon"."acceptedFamily"), "ScrubbedTaxon"."acceptedSpecificEpithet", "ScrubbedTaxon"."morphospeciesSuffix"), ''::text), "ScrubbedTaxon"."acceptedTaxonName"), COALESCE(NULLIF(pg_catalog.concat_ws(' '::text, COALESCE("ScrubbedTaxon"."matchedGenus", "ScrubbedTaxon"."matchedFamily"), "ScrubbedTaxon"."matchedSpecificEpithet", "ScrubbedTaxon"."morphospeciesSuffix"), ''::text), "ScrubbedTaxon"."matchedTaxonName"), "ScrubbedTaxon"."concatenatedScientificName") AS "speciesBinomialWithMorphospecies", "ScrubbedTaxon"."acceptedTaxonName" AS "taxonName", "ScrubbedTaxon"."acceptedScientificNameAuthorship" AS "scientificNameAuthorship", taxonoccurrence.growthform AS "growthForm", plantobservation.reproductivecondition AS "reproductiveCondition", ((threatened_taxonlabel.taxonlabel_id IS NOT NULL))::integer AS threatened_bien, (((cultivated_family_locations.country IS NOT NULL) OR _or(taxonoccurrence.iscultivated, location.iscultivated)))::integer AS cultivated_bien, CASE WHEN (taxonoccurrence.iscultivated IS NOT NULL) THEN taxonoccurrence.cultivatedbasis WHEN (location.iscultivated IS NOT NULL) THEN NULL::text ELSE NULL::text END AS "cultivatedBasis_bien", aggregateoccurrence.notes AS "occurrenceRemarks", _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.sourceaccessioncode AS "taxonOccurrenceID", taxonoccurrence.authortaxoncode AS "authorTaxonCode", aggregateoccurrence.sourceaccessioncode AS "aggregateOrganismObservationID", plantobservation.sourceaccessioncode AS "individualObservationID", plantobservation.authorplantcode AS "individualCode", stemobservation.authorstemcode AS "authorStemCode" FROM (((((((((((((((((((((((((((((source JOIN location USING (source_id)) LEFT JOIN locationevent USING (location_id)) LEFT JOIN location parent_location ON ((parent_location.location_id = location.parent_id))) LEFT JOIN locationplace ON ((locationplace.location_id = COALESCE(parent_location.location_id, location.location_id)))) LEFT JOIN place USING (place_id)) LEFT JOIN coordinates USING (coordinates_id)) LEFT JOIN geoscrub.geoscrub_output ON ((((((ARRAY[geoscrub_output."decimalLatitude"] = ARRAY[coordinates.latitude_deg]) AND (ARRAY[geoscrub_output."decimalLongitude"] = ARRAY[coordinates.longitude_deg])) AND (ARRAY[geoscrub_output.country] = ARRAY[place.country])) AND (ARRAY[geoscrub_output."stateProvince"] = ARRAY[place.stateprovince])) AND (ARRAY[geoscrub_output.county] = ARRAY[place.county])))) LEFT JOIN "newWorld".iso_code_gadm ON ((iso_code_gadm."*GADM country" = COALESCE(geoscrub_output."acceptedCountry", place.country)))) LEFT JOIN "newWorld"."newWorldCountries" ON (("newWorldCountries"."*isoCode" = iso_code_gadm."*2-digit iso code"))) LEFT JOIN geoscrub.county_centroids ON ((((place.country = 'United States'::text) AND (county_centroids.state = COALESCE(geoscrub_output."acceptedStateProvince", place.stateprovince))) AND (county_centroids.county = COALESCE(geoscrub_output."acceptedCounty", place.county))))) LEFT JOIN taxonoccurrence USING (locationevent_id)) LEFT JOIN locationevent parent_event ON ((parent_event.locationevent_id = locationevent.parent_id))) LEFT JOIN project ON ((project.project_id = COALESCE(locationevent.project_id, parent_event.project_id)))) LEFT JOIN stratum ON ((stratum.stratum_id = COALESCE(locationevent.stratum_id, parent_event.stratum_id)))) LEFT JOIN method ON ((method.method_id = COALESCE(locationevent.method_id, parent_event.method_id)))) LEFT JOIN party collector ON ((collector.party_id = taxonoccurrence.collector_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)) LEFT JOIN sourcelist ON ((sourcelist.sourcelist_id = specimenreplicate.institution_id))) LEFT JOIN taxondetermination ON (((taxondetermination.taxonoccurrence_id = taxonoccurrence.taxonoccurrence_id) AND taxondetermination.is_datasource_current))) LEFT JOIN party identifiedby ON ((identifiedby.party_id = taxondetermination.party_id))) LEFT JOIN taxonverbatim USING (taxonverbatim_id)) LEFT JOIN taxonlabel USING (taxonlabel_id)) LEFT JOIN "TNRS"."ScrubbedTaxon" ON (("ScrubbedTaxon"."concatenatedScientificName" = taxonlabel.taxonomicname))) LEFT JOIN family_higher_plant_group ON ((family_higher_plant_group.family = "ScrubbedTaxon"."acceptedFamily"))) LEFT JOIN cultivated_family_locations ON (((cultivated_family_locations.family = "ScrubbedTaxon"."acceptedFamily") AND (cultivated_family_locations.country = COALESCE(geoscrub_output."acceptedCountry", place.country))))) LEFT JOIN threatened_taxonlabel USING (taxonlabel_id)) ORDER BY source.shortname;
|
|
2742 |
SELECT "plot.**".datasource, "plot.**".country, "plot.**"."stateProvince", "plot.**".county, "plot.**".locality, "plot.**"."decimalLatitude", "plot.**"."decimalLongitude", "plot.**"."coordinateUncertaintyInMeters", "plot.**"."coordinateSource_bien", "plot.**"."georeferenceProtocol_bien", "plot.**".geovalid_bien, "plot.**"."isNewWorld_bien", "plot.**"."projectID", "plot.**"."locationID", "plot.**"."locationName", "plot.**".subplot, "plot.**".location__cultivated__bien, "plot.**".locationevent__pkey, "plot.**"."eventDate", "plot.**"."elevationInMeters", "plot.**"."plotArea_ha", "plot.**"."samplingProtocol", "plot.**"."temperature_C", "plot.**".precipitation_m, "plot.**".stratum__name, "plot.**".communities, "plot.**".plot__collectors, sourcelist.name AS "specimenHolderInstitutions", specimenreplicate.collectioncode_dwc AS collection, specimenreplicate.catalognumber_dwc AS "accessionNumber", specimenreplicate.sourceaccessioncode AS "occurrenceID", collector.fullname AS "recordedBy", plantobservation.authorplantcode AS "recordNumber", COALESCE(aggregateoccurrence.collectiondate, "plot.**"."eventDate") AS "dateCollected", taxonverbatim.family AS family_verbatim, COALESCE(taxonverbatim.taxonomicname, NULLIF(pg_catalog.concat_ws(' '::text, taxonverbatim.taxonname, taxonverbatim.author), ''::text), taxonlabel.taxonomicname) AS "scientificName_verbatim", identifiedby.fullname AS "identifiedBy", taxondetermination.determinationdate AS "dateIdentified", taxondetermination.notes AS "identificationRemarks", "ScrubbedTaxon"."matchedFamily" AS family_matched, "ScrubbedTaxon"."matchedTaxonName" AS "taxonName_matched", "ScrubbedTaxon"."matchedScientificNameAuthorship" AS "scientificNameAuthorship_matched", family_higher_plant_group.higher_plant_group AS "higherPlantGroup_bien", "ScrubbedTaxon"."acceptedFamily" AS family, "ScrubbedTaxon"."acceptedGenus" AS genus, COALESCE(COALESCE(NULLIF(pg_catalog.concat_ws(' '::text, COALESCE("ScrubbedTaxon"."acceptedGenus", "ScrubbedTaxon"."acceptedFamily"), "ScrubbedTaxon"."acceptedSpecificEpithet", "ScrubbedTaxon"."morphospeciesSuffix"), ''::text), "ScrubbedTaxon"."acceptedTaxonName"), COALESCE(NULLIF(pg_catalog.concat_ws(' '::text, COALESCE("ScrubbedTaxon"."matchedGenus", "ScrubbedTaxon"."matchedFamily"), "ScrubbedTaxon"."matchedSpecificEpithet", "ScrubbedTaxon"."morphospeciesSuffix"), ''::text), "ScrubbedTaxon"."matchedTaxonName"), "ScrubbedTaxon"."concatenatedScientificName") AS "speciesBinomialWithMorphospecies", "ScrubbedTaxon"."acceptedTaxonName" AS "taxonName", "ScrubbedTaxon"."acceptedScientificNameAuthorship" AS "scientificNameAuthorship", taxonoccurrence.growthform AS "growthForm", plantobservation.reproductivecondition AS "reproductiveCondition", ((threatened_taxonlabel.taxonlabel_id IS NOT NULL))::integer AS threatened_bien, (((cultivated_family_locations.country IS NOT NULL) OR _or(taxonoccurrence.iscultivated, "plot.**".location__cultivated__bien)))::integer AS cultivated_bien, CASE WHEN (taxonoccurrence.iscultivated IS NOT NULL) THEN taxonoccurrence.cultivatedbasis WHEN ("plot.**".location__cultivated__bien IS NOT NULL) THEN NULL::text ELSE NULL::text END AS "cultivatedBasis_bien", aggregateoccurrence.notes AS "occurrenceRemarks", _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.sourceaccessioncode AS "taxonOccurrenceID", taxonoccurrence.authortaxoncode AS "authorTaxonCode", aggregateoccurrence.sourceaccessioncode AS "aggregateOrganismObservationID", plantobservation.sourceaccessioncode AS "individualObservationID", plantobservation.authorplantcode AS "individualCode", stemobservation.authorstemcode AS "authorStemCode" FROM ((((((((((((((("plot.**" LEFT JOIN taxonoccurrence ON ((taxonoccurrence.locationevent_id = "plot.**".locationevent__pkey))) LEFT JOIN party collector ON ((collector.party_id = taxonoccurrence.collector_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)) LEFT JOIN sourcelist ON ((sourcelist.sourcelist_id = specimenreplicate.institution_id))) LEFT JOIN taxondetermination ON (((taxondetermination.taxonoccurrence_id = taxonoccurrence.taxonoccurrence_id) AND taxondetermination.is_datasource_current))) LEFT JOIN party identifiedby ON ((identifiedby.party_id = taxondetermination.party_id))) LEFT JOIN taxonverbatim USING (taxonverbatim_id)) LEFT JOIN taxonlabel USING (taxonlabel_id)) LEFT JOIN "TNRS"."ScrubbedTaxon" ON (("ScrubbedTaxon"."concatenatedScientificName" = taxonlabel.taxonomicname))) LEFT JOIN family_higher_plant_group ON ((family_higher_plant_group.family = "ScrubbedTaxon"."acceptedFamily"))) LEFT JOIN cultivated_family_locations ON (((cultivated_family_locations.family = "ScrubbedTaxon"."acceptedFamily") AND (cultivated_family_locations.country = "plot.**".country)))) LEFT JOIN threatened_taxonlabel USING (taxonlabel_id)) ORDER BY "plot.**".datasource;
|
2735 |
2743 |
|
2736 |
2744 |
|
2737 |
2745 |
--
|
... | ... | |
3950 |
3958 |
|
3951 |
3959 |
|
3952 |
3960 |
--
|
3953 |
|
-- Name: plot.**; Type: VIEW; Schema: public; Owner: -
|
3954 |
|
--
|
3955 |
|
|
3956 |
|
CREATE VIEW "plot.**" AS
|
3957 |
|
SELECT source.shortname AS datasource, COALESCE(geoscrub_output."acceptedCountry", place.country) AS country, COALESCE(geoscrub_output."acceptedStateProvince", place.stateprovince) AS "stateProvince", COALESCE(geoscrub_output."acceptedCounty", place.county) AS county, location.locationnarrative AS locality, CASE WHEN (coordinates.latitude_deg IS NOT NULL) THEN coordinates.latitude_deg ELSE county_centroids.latitude END AS "decimalLatitude", CASE WHEN (coordinates.latitude_deg IS NOT NULL) THEN coordinates.longitude_deg ELSE county_centroids.longitude END AS "decimalLongitude", CASE WHEN (coordinates.latitude_deg IS NOT NULL) THEN coordinates.coordsaccuracy_m ELSE _km_to_m(county_centroids.error_km) END AS "coordinateUncertaintyInMeters", CASE WHEN (coordinates.latitude_deg IS NOT NULL) THEN 'source data'::coordinatesource WHEN (county_centroids.row_num IS NOT NULL) THEN 'georeferencing'::coordinatesource ELSE NULL::coordinatesource END AS "coordinateSource_bien", CASE WHEN (coordinates.latitude_deg IS NOT NULL) THEN NULL::text WHEN (county_centroids.row_num IS NOT NULL) THEN 'county centroid'::text ELSE NULL::text END AS "georeferenceProtocol_bien", (geoscrub_output.geovalid)::integer AS geovalid_bien, ("newWorldCountries"."isNewWorld")::integer AS "isNewWorld_bien", COALESCE(project.sourceaccessioncode, project.projectname) AS "projectID", COALESCE(location.sourceaccessioncode, NULLIF(pg_catalog.concat_ws('; '::text, COALESCE(parent_location.sourceaccessioncode, parent_location.authorlocationcode), location.authorlocationcode), ''::text)) AS "locationID", COALESCE(parent_location.authorlocationcode, location.authorlocationcode) AS "locationName", CASE WHEN (parent_location.location_id IS NOT NULL) THEN location.authorlocationcode ELSE NULL::text END AS subplot, location.iscultivated AS location__cultivated__bien, locationevent.locationevent_id AS locationevent__pkey, COALESCE(locationevent.obsstartdate, parent_event.obsstartdate) AS "eventDate", COALESCE(location.elevation_m, parent_location.elevation_m) AS "elevationInMeters", _m2_to_ha(COALESCE(location.area_m2, parent_location.area_m2)) AS "plotArea_ha", method.name AS "samplingProtocol", COALESCE(locationevent.temperature_c, parent_event.temperature_c) AS "temperature_C", COALESCE(locationevent.precipitation_m, parent_event.precipitation_m) AS precipitation_m, stratum.stratumname AS stratum__name, COALESCE(locationevent__communities__array(locationevent.locationevent_id), locationevent__communities__array(parent_event.locationevent_id)) AS communities, COALESCE(locationevent__contributors__array(locationevent.locationevent_id), locationevent__contributors__array(parent_event.locationevent_id)) AS plot__collectors FROM ((((((((((((((source JOIN location USING (source_id)) LEFT JOIN locationevent USING (location_id)) LEFT JOIN location parent_location ON ((parent_location.location_id = location.parent_id))) LEFT JOIN locationplace ON ((locationplace.location_id = COALESCE(parent_location.location_id, location.location_id)))) LEFT JOIN place USING (place_id)) LEFT JOIN coordinates USING (coordinates_id)) LEFT JOIN geoscrub.geoscrub_output ON ((((((ARRAY[geoscrub_output."decimalLatitude"] = ARRAY[coordinates.latitude_deg]) AND (ARRAY[geoscrub_output."decimalLongitude"] = ARRAY[coordinates.longitude_deg])) AND (ARRAY[geoscrub_output.country] = ARRAY[place.country])) AND (ARRAY[geoscrub_output."stateProvince"] = ARRAY[place.stateprovince])) AND (ARRAY[geoscrub_output.county] = ARRAY[place.county])))) LEFT JOIN "newWorld".iso_code_gadm ON ((iso_code_gadm."*GADM country" = COALESCE(geoscrub_output."acceptedCountry", place.country)))) LEFT JOIN "newWorld"."newWorldCountries" ON (("newWorldCountries"."*isoCode" = iso_code_gadm."*2-digit iso code"))) LEFT JOIN geoscrub.county_centroids ON ((((place.country = 'United States'::text) AND (county_centroids.state = COALESCE(geoscrub_output."acceptedStateProvince", place.stateprovince))) AND (county_centroids.county = COALESCE(geoscrub_output."acceptedCounty", place.county))))) LEFT JOIN locationevent parent_event ON ((parent_event.locationevent_id = locationevent.parent_id))) LEFT JOIN project ON ((project.project_id = COALESCE(locationevent.project_id, parent_event.project_id)))) LEFT JOIN stratum ON ((stratum.stratum_id = COALESCE(locationevent.stratum_id, parent_event.stratum_id)))) LEFT JOIN method ON ((method.method_id = COALESCE(locationevent.method_id, parent_event.method_id))));
|
3958 |
|
|
3959 |
|
|
3960 |
|
--
|
3961 |
3961 |
-- Name: project_project_id_seq; Type: SEQUENCE; Schema: public; Owner: -
|
3962 |
3962 |
--
|
3963 |
3963 |
|
... | ... | |
8898 |
8898 |
|
8899 |
8899 |
|
8900 |
8900 |
--
|
|
8901 |
-- Name: stratum; Type: ACL; Schema: public; Owner: -
|
|
8902 |
--
|
|
8903 |
|
|
8904 |
REVOKE ALL ON TABLE stratum FROM PUBLIC;
|
|
8905 |
REVOKE ALL ON TABLE stratum FROM bien;
|
|
8906 |
GRANT ALL ON TABLE stratum TO bien;
|
|
8907 |
GRANT SELECT ON TABLE stratum TO bien_read;
|
|
8908 |
|
|
8909 |
|
|
8910 |
--
|
|
8911 |
-- Name: plot.**; Type: ACL; Schema: public; Owner: -
|
|
8912 |
--
|
|
8913 |
|
|
8914 |
REVOKE ALL ON TABLE "plot.**" FROM PUBLIC;
|
|
8915 |
REVOKE ALL ON TABLE "plot.**" FROM bien;
|
|
8916 |
GRANT ALL ON TABLE "plot.**" TO bien;
|
|
8917 |
GRANT SELECT ON TABLE "plot.**" TO bien_read;
|
|
8918 |
|
|
8919 |
|
|
8920 |
--
|
8901 |
8921 |
-- Name: sourcelist; Type: ACL; Schema: public; Owner: -
|
8902 |
8922 |
--
|
8903 |
8923 |
|
... | ... | |
8928 |
8948 |
|
8929 |
8949 |
|
8930 |
8950 |
--
|
8931 |
|
-- Name: stratum; Type: ACL; Schema: public; Owner: -
|
8932 |
|
--
|
8933 |
|
|
8934 |
|
REVOKE ALL ON TABLE stratum FROM PUBLIC;
|
8935 |
|
REVOKE ALL ON TABLE stratum FROM bien;
|
8936 |
|
GRANT ALL ON TABLE stratum TO bien;
|
8937 |
|
GRANT SELECT ON TABLE stratum TO bien_read;
|
8938 |
|
|
8939 |
|
|
8940 |
|
--
|
8941 |
8951 |
-- Name: taxondetermination; Type: ACL; Schema: public; Owner: -
|
8942 |
8952 |
--
|
8943 |
8953 |
|
... | ... | |
9269 |
9279 |
|
9270 |
9280 |
|
9271 |
9281 |
--
|
9272 |
|
-- Name: plot.**; Type: ACL; Schema: public; Owner: -
|
9273 |
|
--
|
9274 |
|
|
9275 |
|
REVOKE ALL ON TABLE "plot.**" FROM PUBLIC;
|
9276 |
|
REVOKE ALL ON TABLE "plot.**" FROM bien;
|
9277 |
|
GRANT ALL ON TABLE "plot.**" TO bien;
|
9278 |
|
GRANT SELECT ON TABLE "plot.**" TO bien_read;
|
9279 |
|
|
9280 |
|
|
9281 |
|
--
|
9282 |
9282 |
-- Name: projectcontributor; Type: ACL; Schema: public; Owner: -
|
9283 |
9283 |
--
|
9284 |
9284 |
|
schemas/vegbien.sql: analytical_stem_view: use plot.** to obtain plot-related fields, so that the same code does not need to be maintained in both analytical_stem_view and plot.**