Coder Social home page Coder Social logo

Ochrana about pladias-dwc-export HOT 1 OPEN

Jules- avatar Jules- commented on June 22, 2024
Ochrana

from pladias-dwc-export.

Comments (1)

Jules- avatar Jules- commented on June 22, 2024 1

Po úprave dle e-mailu by to mohlo být takto:

WITH temp_taxons AS (
    SELECT taxons.id, name_lat,
           CASE WHEN value != 200000 THEN TRUE
                ELSE FALSE END AS is_protected
    FROM taxons
        LEFT JOIN measurements.data_enum AS de ON taxons.id = de.taxon_id
    WHERE de.trait_id = 200001 AND entry_type = 1 AND is_enabled
)
SELECT
    CONCAT('BU-SAV:PLADIAS:', r.id) AS occurrenceID,
    t.name_lat AS scientificName,
    CASE WHEN is_protected THEN round(r.latitude * 100) / 100
        ELSE r.latitude END AS decimalLatitude,
    CASE WHEN is_protected THEN round(r.longitude * 100) / 100
         ELSE r.longitude END AS decimalLongitude,
    CASE
        WHEN r.datum_precision = 'Y' THEN TO_CHAR(r.datum, 'YYYY')
        WHEN r.datum_precision = 'M' THEN TO_CHAR(r.datum, 'YYYY-MM')
        WHEN r.datum_precision = 'D' THEN TO_CHAR(r.datum, 'YYYY-MM-DD')
        ELSE NULL
        END AS eventDate,
    r.locality,
    r.altitude_min AS minimumElevationInMeters,
    r.altitude_max AS maximumElevationInMeters,
    r.comment AS occurrenceRemarks,
    (
        SELECT string_agg(CASE WHEN a.name = '' THEN a.surname ELSE CONCAT(a.name, ' ', a.surname) END, '|')
        FROM atlas.records_authors
                 INNER JOIN atlas.authors AS a ON records_authors.authors_id = a.id
        WHERE records_id = r.id) AS recordedBy,
    r.source,
    r.environment,
    CASE
        WHEN r.validation_status IN (0, 1) THEN 'verification required'
        WHEN r.validation_status = 3 THEN 'verified'
        ELSE NULL
        END AS identificationVerificationStatus,
    r.original_name AS verbatimScientificName,
    CASE WHEN is_protected THEN NULL
         ELSE r.gps_coords_precision END AS coordinateUncertaintyInMeters,
    CASE WHEN is_protected THEN 0.01
         ELSE NULL END AS coordinatePrecision
FROM
    atlas.records AS r
        LEFT JOIN temp_taxons AS t ON r.taxon_id = t.id
        LEFT JOIN atlas.projects AS p ON r.project_id = p.id
WHERE
    r.validation_status != 2

from pladias-dwc-export.

Related Issues (2)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.