Search in sources :

Example 1 with DefaultBoundingPolygon

use of org.apache.sis.metadata.iso.extent.DefaultBoundingPolygon in project geotoolkit by Geomatys.

the class DimapAccessor method fillMetadata.

/**
 * Converts the given dimap document in a metadata object.
 * Since there is no one to one relation between ISO 19115 and Dimap,
 * the returned metadata is a best effort relation.
 *
 * @param doc
 * @param metadata : metadata to fill, if null it will create one.
 * @return Metadata, never null
 */
public static DefaultMetadata fillMetadata(final Element doc, DefaultMetadata metadata) throws IOException {
    if (metadata == null) {
        metadata = new DefaultMetadata();
    } else {
        // To ensure we don't modify the original
        if (metadata instanceof MI_Metadata) {
            metadata = new MI_Metadata(metadata);
        } else {
            metadata = new DefaultMetadata(metadata);
        }
    }
    String thumbnail = null;
    String name = null;
    // Dimap_Document STRUCTURE
    // 
    // <Metadata_Id/>                    - Mandatory
    // <Dataset_Id/>                     - Mandatory
    // <Dataset_Frame/>                  - Optional
    // <Coordinate_Reference_System/>    - Mandatory
    // <Raster_CS/>                      - Mandatory
    // <Geoposition/>                    - Mandatory
    // <Production/>                     - Mandatory
    // <Quality_Assessment/>             - Optional
    // <Raster_Dimensions/>              - Mandatory
    // <Raster_Encoding/>                - Mandatory
    // <Data_Processing/>                - Mandatory
    // <Data_Access/>                    - Mandatory
    // <Image_Display/>                  - Mandatory
    // <Image_Interpretation/>           - Mandatory
    // <Dataset_Sources/>                - Mandatory
    // <Data_Strip/>                     - Mandatory
    // Default values
    metadata.setCharacterSets(Collections.singleton(StandardCharsets.UTF_8));
    metadata.setLanguage(Locale.ENGLISH);
    metadata.setDateStamp(new Date());
    // <xsd:element minOccurs="1" maxOccurs="1" ref="Dataset_Id"/> ----------
    final Element datasetID = firstElement(doc, TAG_DATASET_ID);
    if (datasetID != null) {
        // MAPPING
        // 
        // <DATASET_NAME/>       → used to build : MetaData.fileIdentifier
        // <DATASET_TN_PATH/>    → ?
        // <DATASET_TN_FORMAT/>  → ?
        // <DATASET_QL_PATH/>    → ?
        // <DATASET_QL_FORMAT/>  → ?
        // <COPYRIGHT/>          → MetaData.metadataConstraints > LegalConstraints.otherConstraints
        // → MetaData.identificationInfo > resourcesConstraints > LegalConstraints.otherConstraints
        final String copyright = textValueSafe(datasetID, TAG_DATASET_COPYRIGHT, String.class);
        thumbnail = textAttributeValueSafe(datasetID, TAG_DATASET_TN_PATH, ATTRIBUTE_HREF, String.class);
        name = textValueSafe(datasetID, TAG_DATASET_NAME, String.class);
        // MetaData > FileIdentifier
        metadata.setFileIdentifier(name.replaceAll(":", "_").replaceAll(" ", "_").replaceAll("/", "_"));
        // MetaData > MetadataConstraints
        final Restriction restriction = Restriction.COPYRIGHT;
        final DefaultLegalConstraints constraints = new DefaultLegalConstraints();
        constraints.setUseConstraints(Collections.singleton(restriction));
        constraints.setOtherConstraints(Collections.singleton(new SimpleInternationalString(copyright)));
        metadata.getMetadataConstraints().add(constraints);
        // duplicate ?
        final AbstractIdentification identification = getIdentificationInfo(metadata);
        identification.getResourceConstraints().add(constraints);
    }
    // <xsd:element minOccurs="0" maxOccurs="1" ref="Dataset_Frame"/> -------
    // Has been set from the geotiff informations
    final Element datasetFrame = firstElement(doc, TAG_DATASET_FRAME);
    if (datasetFrame != null) {
        if (metadata instanceof MI_Metadata) {
            Geometry geometry = null;
            try {
                geometry = readDatasetVertex(doc);
            } catch (NoSuchAuthorityCodeException ex) {
                throw new IOException("Exception when creating the bounding geometry : ", ex);
            } catch (FactoryException ex) {
                throw new IOException("Exception when creating the bounding geometry : ", ex);
            }
            // MetaData > DataIdentification > Extent > BoundingPolygon
            if (geometry != null) {
                final DefaultBoundingPolygon boundingPolygon = new DefaultBoundingPolygon();
                boundingPolygon.setPolygons(Collections.singleton(geometry));
                final DefaultGeographicDescription geographicDesc = new DefaultGeographicDescription();
                // not safe
                final Element gridReference = firstElement(doc, TAG_SCENE_GRID_REFERENCE);
                final String geographicId;
                if (gridReference != null) {
                    final String rawGeoId = gridReference.getTextContent();
                    geographicId = rawGeoId.substring(0, 3) + "-" + rawGeoId.substring(3);
                } else {
                    final String[] fileIdSplited = metadata.getFileIdentifier().split("-");
                    geographicId = fileIdSplited[0].substring(fileIdSplited[0].length() - 3) + "-" + fileIdSplited[1].substring(0, 3);
                }
                geographicDesc.setGeographicIdentifier(new DefaultIdentifier(geographicId));
                final DefaultExtent extent = getExtent(metadata);
                extent.getGeographicElements().add(boundingPolygon);
                extent.getGeographicElements().add(geographicDesc);
            }
        }
    }
    // <xsd:element minOccurs="1" maxOccurs="1"  ref="Production"/> ---------
    // Can be changed in a Responsible party information
    final Element production = firstElement(doc, TAG_PRODUCTION);
    if (production != null) {
        // MAPPING
        // 
        // <DATASET_PRODUCER_NAME/>      → MetaData.dataQualityInfo > DataQuality.lineage > Lineage.processSteps > ProcessStep.processors > ResponsibleParty.organisationName
        // <DATASET_PRODUCER_URL/>       → ?
        // <DATASET_PRODUCTION_DATE/>    → MetaData.dataQualityInfo > DataQuality.lineage > Lineage.processSteps > ProcessStep.date
        // <PRODUCT_TYPE/>               → ?
        // <PRODUCT_INFO/>               → MetaData.dataQualityInfo > DataQuality.lineage > Lineage.processSteps > ProcessStep.description
        // <JOB_ID/>                     → MetaData.dataQualityInfo > DataQuality.lineage > Lineage.processSteps > ProcessStep > Processing.identifier > Identifier.code
        // <Production_Facility>         Occurs : 1 to 1
        // <SOFTWARE_NAME/>          → MetaData.dataQualityInfo > DataQuality.lineage > Lineage.processSteps > ProcessStep.processingInfo > Processing.softwareReference > Citation.title
        // <SOFTWARE_VERSION/>       → MetaData.dataQualityInfo > DataQuality.lineage > Lineage.processSteps > ProcessStep.processingInfo > Processing.softwareReference > Citation.edition
        // <PROCESSING_CENTER/>      → MetaData.dataQualityInfo > DataQuality.lineage > Lineage.processSteps > ProcessStep.processingInfo > Processing.softwareReference > Citation.citedResponsibleParties > ResponsibleParty.organisationName
        // </Production_Facility>
        final String jobId = textValueSafe(production, TAG_JOB_ID, String.class);
        final String productType = textValueSafe(production, TAG_PRODUCT_TYPE, String.class);
        final String productInfo = textValueSafe(production, TAG_PRODUCT_INFO, String.class);
        final String producerName = textValueSafe(production, TAG_DATASET_PRODUCER_NAME, String.class);
        final Date productionDate = textValueSafe(production, TAG_DATASET_PRODUCTION_DATE, Date.class);
        final Element producerEle = firstElement(production, TAG_DATASET_PRODUCER_URL);
        URI producerURL = null;
        try {
            producerURL = new URI(producerEle.getAttribute(ATT_HREF));
        } catch (URISyntaxException ex) {
            LOGGER.log(Level.WARNING, ex.getLocalizedMessage(), ex);
        }
        final Element facility = firstElement(production, TAG_PRODUCTION_FACILITY);
        /**
         * Fills DataQualityInfo
         */
        // MetaData > DataQuality > Lineage > ProcessStep
        final DefaultResponsibleParty responsibleParty = new DefaultResponsibleParty(Role.ORIGINATOR);
        responsibleParty.setOrganisationName(new SimpleInternationalString(producerName));
        final DefaultProcessStep processStep = getProcessStep(metadata);
        processStep.setDescription(new SimpleInternationalString(productInfo));
        processStep.setDate(productionDate);
        processStep.getProcessors().add(responsibleParty);
        // MetaData > DataQuality > Lineage > ProcessStep > Processing > Identifier
        if (jobId != null) {
            final DefaultProcessing processing = getProcessingInfo(metadata);
            processing.setIdentifier(new DefaultIdentifier(jobId));
        }
        // MetaData > DataQuality > Lineage > ProcessStep > Processing > SoftwareReferences
        if (facility != null) {
            final String softwareName = textValueSafe(facility, TAG_PRODUCTION_FACILITY_SOFTWARE_NAME, String.class);
            final String softwareVersion = textValueSafe(facility, TAG_PRODUCTION_FACILITY_SOFTWARE_VERSION, String.class);
            final String productionCenter = textValueSafe(facility, TAG_PRODUCTION_FACILITY_PROCESSING_CENTER, String.class);
            final DefaultCitation softCitation = new DefaultCitation();
            softCitation.setTitle(new SimpleInternationalString(softwareName));
            softCitation.setEdition(new SimpleInternationalString(softwareVersion));
            if (productionCenter != null) {
                final DefaultResponsibleParty softResponsibleParty = new DefaultResponsibleParty();
                softResponsibleParty.setOrganisationName(new SimpleInternationalString(productionCenter));
                softCitation.getCitedResponsibleParties().add(softResponsibleParty);
            }
            final DefaultProcessing processing = getProcessingInfo(metadata);
            processing.getSoftwareReferences().add(softCitation);
        }
    }
    // <xsd:element minOccurs="1" maxOccurs="1"  ref="Raster_Dimensions"/> --
    // Has been set from the geotiff informations
    final Element rasterDim = firstElement(doc, TAG_RASTER_DIMENSIONS);
    if (rasterDim != null) {
        // MAPPING
        // 
        // <NCOLS/>  → MetaData.spatialRepresentationInfo > GridSpatialRepresentation.axisDimensionProperties > Dimension.dimensionSize
        // <NROWS/>  → MetaData.spatialRepresentationInfo > GridSpatialRepresentation.axisDimensionProperties > Dimension.dimensionSize
        // <NBANDS/> → ?
        final Integer ncols = textValueSafe(rasterDim, TAG_NCOLS, Integer.class);
        final Integer nrows = textValueSafe(rasterDim, TAG_NROWS, Integer.class);
        /**
         * Fills SpatialRepresentationInfo
         */
        // MetaData > GridSpatialRepresentation > Dimension
        final DefaultDimension rowDim = new DefaultDimension();
        rowDim.setDimensionSize(nrows);
        rowDim.setDimensionName(DimensionNameType.ROW);
        final DefaultDimension columnDim = new DefaultDimension();
        columnDim.setDimensionSize(ncols);
        columnDim.setDimensionName(DimensionNameType.COLUMN);
        final DefaultGridSpatialRepresentation gridSpacialRepr = (DefaultGridSpatialRepresentation) getSpatialRepresentationInfo(metadata);
        final List<Dimension> axisDimensions = gridSpacialRepr.getAxisDimensionProperties();
        axisDimensions.add(rowDim);
        axisDimensions.add(columnDim);
    }
    // <xsd:element minOccurs="1" maxOccurs="1"  ref="Data_Processing"/> ----
    final Element dataProcessing = firstElement(doc, TAG_DATA_PROCESSING);
    if (dataProcessing != null) {
        // MAPPING
        // 
        // <PROCESSING_LEVEL/>                   → ?
        // <GEOMETRIC_PROCESSING/>               → ?
        // <RADIOMETRIC_PROCESSING/>             → ?
        // <SPECTRAL_PROCESSING/>                → ?
        // <Processing_Options>                  Occurs : 1 to 1
        // <MEAN_RECTIFICATION_ELEVATION/>   → ?
        // <LINE_SHIFT/>                     → ?
        // <DECOMPRESSION_TYPE/>             → ?
        // <SWIR_BAND_REGISTRATION_FLAG/>    → ?
        // <X_BANDS_REGISTRATION_FLAG/>      → ?
        // <RESAMPLING_METHOD/>              → ?
        // <Dynamic_Stretch>                 Occurs : 0 to 1
        // <Thresholds>                  Occurs : 1 to n
        // <BAND_INDEX/>             → MetaData.contentInfo > ImageDescription.dimensions > Band.descriptor
        // <LOW_THRESHOLD/>          → MetaData.contentInfo > ImageDescription.dimensions > Band.minValue
        // <HIGH_THRESHOLD/>         → MetaData.contentInfo > ImageDescription.dimensions > Band.maxValue
        // </Thresholds>
        // <Dynamic_Stretch>
        // <Deconvolution>                   Occurs : 0 to 1
        // <LINE_SHIFT/>                 → ?
        // <DECOMPRESSION_TYPE/>         → ?
        // <Deconvolution>
        // <Sampling_Step>                   Occurs : 0 to 1
        // <SAMPLING_STEP_X/>            → ?
        // <SAMPLING_STEP_Y/>            → ?
        // <Sampling_Step>
        // <SuperMode_Processing>            Occurs : 0 to 1
        // <SM_CORRELATION_NEEDED/>      → ?
        // <SM_RAW_GRID_FILTERING/>      → ?
        // <SM_PROCESSING_TYPE/>         → ?
        // <SuperMode_Processing>
        // <Correction_Algorithm>            Occurs : 0 to n
        // <ALGORITHM_TYPE/>             → MetaData.dataQualityInfo > DataQuality.lineage > Lineage.processSteps > ProcessStep.processingInfo > Processing.algorithms > Algorithm.description
        // <ALGORITHM_NAME/>             → MetaData.dataQualityInfo > DataQuality.lineage > Lineage.processSteps > ProcessStep.processingInfo > Processing.algorithms > Algorithm.citation > Citation.title
        // <ALGORITHM_ACTIVATION/>       → ?
        // <Correction_Algorithm>
        // ...
        // </Processing_Options>
        // <Regions_Of_Interest>                 Occurs : 0 to 1
        // <Region_Of_Interest>              Occurs : 1 to n
        // <COL_MIN/>                    → ?
        // <ROW_MIN/>                    → ?
        // <COL_MAX/>                    → ?
        // <ROW_MAX/>                    → ?
        // </Region_Of_Interest>
        // ...
        // </Regions_Of_Interest>
        final String algoType = textValueSafe(dataProcessing, TAG_DATA_PROCESSING_ALGORITHM_TYPE, String.class);
        final String algoName = textValueSafe(dataProcessing, TAG_DATA_PROCESSING_ALGORITHM_NAME, String.class);
        final String processingLevel = textValueSafe(dataProcessing, TAG_DATA_PROCESSING_PROCESSING_LEVEL, String.class);
        // MetaData > DataQuality > Lineage > ProcessStep > Processing > Algorithm
        if (algoName != null && algoType != null) {
            final DefaultCitation citation = new DefaultCitation();
            citation.setTitle(new SimpleInternationalString(algoName));
            final DefaultAlgorithm algorithm = new DefaultAlgorithm();
            algorithm.setDescription(new SimpleInternationalString(algoType));
            algorithm.setCitation(citation);
            final DefaultProcessing processing = getProcessingInfo(metadata);
            processing.getAlgorithms().add(algorithm);
        }
        /**
         * Fills ContentInfo
         */
        // MetaData > ImageDescription > Dimension
        final Element processingOpts = firstElement(dataProcessing, TAG_PROCESSING_OPTIONS);
        if (processingOpts != null) {
            final Element dynamicStretch = firstElement(dataProcessing, TAG_DYNAMIC_STRETCH);
            if (dynamicStretch != null) {
                final List<Element> thresholds = getListElements(dynamicStretch, TAG_THRESHOLDS);
                for (int i = 0, len = thresholds.size(); i < len; i++) {
                    final Element threshold = (Element) thresholds.get(i);
                    final int bandIndex = textValueSafe(threshold, TAG_BAND_INDEX, Integer.class);
                    final Double lowThreshold = textValueSafe(threshold, TAG_LOW_THRESHOLD, Double.class);
                    final Double highThreshold = textValueSafe(threshold, TAG_HIGH_THRESHOLD, Double.class);
                    final DefaultNameFactory factory = new DefaultNameFactory();
                    final TypeName tname = factory.createTypeName(null, "BAND_INDEX");
                    final MemberName memberName = factory.createMemberName(null, String.valueOf(bandIndex), tname);
                    final DefaultBand dimension = getBandDimension(metadata, bandIndex);
                    dimension.setMinValue(lowThreshold);
                    dimension.setMaxValue(highThreshold);
                    dimension.setSequenceIdentifier(memberName);
                }
            }
        }
        // MetaData > ContentInfo (ImageDescription) > ProcessingLevelCode
        if (processingLevel != null) {
            final DefaultImageDescription contentInfo = (DefaultImageDescription) getContentInfo(metadata);
            contentInfo.setProcessingLevelCode(new DefaultIdentifier(processingLevel));
        }
    }
    // <xsd:element minOccurs="1" maxOccurs="1"  ref="Data_Access"/> --------
    final Element dataAccess = firstElement(doc, TAG_DATA_ACCESS);
    if (dataAccess != null) {
        // MAPPING
        // 
        // <DATA_FILE_FORMAT/>       → Metadata.identificationInfo > DataIdentification.resourceFormats > Format.name and Format.version
        // <DATA_FILE_FORMAT_DESC/>  → ?
        // <DATA_FILE_ORGANISATION/> → ?
        // <Data_File>               Occurs : 1 to 1
        // <DATA_FILE_PATH/>      → ?
        // </Data_File>
        final Element formatTag = firstElement(dataAccess, TAG_DATA_FILE_FORMAT);
        // MetaData > DataIdentification > Format
        if (formatTag != null) {
            final String version = formatTag.getAttribute(ATT_VERSION);
            final String formatName = formatTag.getTextContent();
            final DefaultFormat format = new DefaultFormat();
            format.setName(new SimpleInternationalString(formatName));
            format.setVersion(new SimpleInternationalString(version));
            final AbstractIdentification idf = getIdentificationInfo(metadata);
            idf.getResourceFormats().add(format);
        }
    }
    // <xsd:element minOccurs="1" maxOccurs="1" ref="Image_Interpretation"/>
    final Element imageInter = firstElement(doc, TAG_IMAGE_INTERPRETATION);
    if (imageInter != null) {
        // MAPPING
        // 
        // <Spectral_Band_Info>               Occurs : 1 to n
        // <BAND_INDEX/>                  → MetaData.contentInfo > ImageDescription.dimensions > Band.descriptor
        // <BAND_DESCRIPTION/>            → MetaData.contentInfo > ImageDescription.dimensions > Band.descriptor
        // <PHYSICAL_UNIT/>               → MetaData.contentInfo > ImageDescription.dimensions > Band.Units
        // <PHYSICAL_GAIN/>               → MetaData.contentInfo > ImageDescription.dimensions > Band.scaleFactor
        // <PHYSICAL_BIAS/>               → MetaData.contentInfo > ImageDescription.dimensions > Band.offset
        // <PHYSICAL_CALIBRATION_DATE/>   → ?
        // </Spectral_Band_Info>
        // ...
        /**
         * Fills ContentInfo
         */
        final List<Element> spectrals = getListElements(imageInter, TAG_SPECTRAL_BAND_INFO);
        if (spectrals != null) {
            final Element physicalUnitElem = firstElement(imageInter, TAG_PHYSICAL_UNIT);
            final int nbits = readNBits(doc);
            // MetaData > ImageDescription > Dimensions
            for (int i = 0, len = spectrals.size(); i < len; i++) {
                final Element spectre = (Element) spectrals.get(i);
                final int bandIndex = textValueSafe(spectre, TAG_BAND_INDEX, Integer.class);
                final String bandDesc = textValueSafe(spectre, TAG_BAND_DESCRIPTION, String.class);
                final Double physicalGain = textValueSafe(spectre, TAG_PHYSICAL_GAIN, Double.class);
                final Double physicalBias = textValueSafe(spectre, TAG_PHYSICAL_BIAS, Double.class);
                String physicalUnit = textValueSafe(spectre, TAG_PHYSICAL_UNIT, String.class);
                physicalUnit = physicalUnit.substring(physicalUnit.indexOf("(") + 1, physicalUnit.indexOf(")"));
                // final Unit unit = Units.valueOf(physicalUnit);
                final DefaultBand dimension = getBandDimension(metadata, bandIndex);
                dimension.setBitsPerValue(nbits);
                dimension.setDescriptor(new SimpleInternationalString(bandDesc));
                dimension.setScaleFactor(1 / physicalGain);
                dimension.setOffset(physicalBias);
            // dimension.setUnits(unit);
            }
        }
    }
    // <xsd:element minOccurs="1" maxOccurs="1" ref="Dataset_Sources"/> -----
    // Could be mapped to Aquisition informations
    final Element datasetSources = firstElement(doc, TAG_DATASET_SOURCES);
    if (datasetSources != null) {
        // MAPPING
        // 
        // <Source_Information>                      Occurs : 1 to 3
        // <SOURCE_ID/>                           → ?
        // <SOURCE_TYPE/>                         → ?
        // <SOURCE_DESCRIPTION/>                  → Metadata.identificationInfo > DataIdentification.abstract
        // <Source_Frame>                         Occurs : 0 to 1
        // <Vertex>                           Occurs : 4 to 4
        // <FRAME_LON/>                   → ?
        // <FRAME_LAT/>                   → ?
        // <FRAME_ROW/>                   → ?
        // <FRAME_COL/>                   → ?
        // <FRAME_X/>                     → ?
        // <FRAME_Y/>                     → ?
        // </Vertex>
        // ...
        // </Source_Frame>
        // <Scene_Source>                         Occurs : 0 to 1
        // <MISSION/>                         → MetaData.acquisitionInformation > AcquisitionInformation.operations > Operations.description
        // AND MetaData.acquisitionInformation > AcquisitionInformation.plateforms > Platform.identifier > Identifier.code
        // AND MetaData.acquisitionInformation > AcquisitionInformation.plateforms > Platform.Citation > Citation.title
        // AND MetaData.acquisitionInformation > AcquisitionInformation.plateforms > Platform.description
        // AND Metadata.identificationInfo > DataIdentification.abstract
        // AND Metadata.identificationInfo > DataIdentification.citation > Citation.title
        // 
        // <MISSION_INDEX/>                   → MetaData.acquisitionInformation > AcquisitionInformation.operations > Operations.identifier > Identifier.code
        // AND MetaData.acquisitionInformation > AcquisitionInformation.plateforms > Platform.identifier > Identifier.code
        // AND MetaData.acquisitionInformation > AcquisitionInformation.plateforms > Platform.description
        // AND Metadata.identificationInfo > DataIdentification.abstract
        // AND Metadata.identificationInfo > DataIdentification.citation > Citation.title
        // AND Metadata.identificationInfo > DataIdentification.spatialResolutions > Resolution.distance
        // 
        // <INSTRUMENT/>                      → MetaData.acquisitionInformation > AcquisitionInformation.instruments > Instrument.description
        // <INSTRUMENT_INDEX/>                → MetaData.acquisitionInformation > AcquisitionInformation.instruments > Instrument.identifier > Identifier.code
        // <SENSOR_CODE/>                     → Metadata.identificationInfo > DataIdentification.abstract
        // AND Metadata.identificationInfo > DataIdentification.resolution > Resolution.
        // 
        // <IMAGING_DATE/>                    → MetaData.identificationInfo > DataIdentification.citation > Citation.dates > CitationDate
        // <IMAGING_TIME/>                    → MetaData.identificationInfo > DataIdentification.citation > Citation.dates > CitationDate
        // <GRID_REFERENCE/>                  → ?
        // <SHIFT_VALUE/>                     → ?
        // <INCIDENCE_ANGLE/>                 → ?
        // <THEORETICAL_RESOLUTION/>          → ?
        // <SUN_AZIMUTH/>                     → MetaData.contentInfo > ImageDescription.processingLevelCode > Identifier.code
        // <SUN_ELEVATION/>                   → MetaData.contentInfo > ImageDescription.illuminationAzimuthAngle
        // <SCENE_PROCESSING_LEVEL/>          → MetaData.contentInfo > ImageDescription.illuminationElevationAngle
        // <VIEWING_ANGLE/>                   → ?
        // <Imaging_Parameters>               Occurs : 1 to 1
        // <REVOLUTION_NUMBER/>           → ?
        // <COMPRESSION_MODE/>            → ?
        // <DIRECT_PLAYBACK_INDICATOR/>   → ?
        // <REFOCUSING_STEP_NUM/>         → ?
        // <COUPLED_MODE_FLAG/>           → ?
        // <SWATH_MODE/>                  → ?
        // </Imaging_Parameters>
        // </Scene_Source>
        // <Quality_Assessment>                   Occurs : 0 to 1
        // <QUALITY_TABLES/>                  → ?
        // <Quality_Parameter>                Occurs : 1 to n
        // <QUALITY_PARAMETER_CODE/>      → ?
        // <QUALITY_PARAMETER_DESC/>      → ?
        // <QUALITY_PARAMETER_VALUE/>     → ?
        // </Quality_Parameter>
        // </Quality_Assessment>
        // </Source_Information>
        // ...
        final Element sourceInfo = firstElement(datasetSources, TAG_SOURCE_INFORMATION);
        if (sourceInfo != null) {
            final String sourceDesc = textValueSafe(sourceInfo, TAG_SOURCE_DESCRIPTION, String.class);
            final String sourceType = textValueSafe(sourceInfo, TAG_SOURCE_TYPE, String.class);
            /**
             * Fills IdentificationInfo, AcquisitionInfo and ContentInfo
             */
            final Element sceneSource = firstElement(sourceInfo, TAG_SCENE_SOURCE);
            if (sceneSource != null) {
                final String imagingDate = textValueSafe(sceneSource, TAG_SCENE_IMAGING_DATE, String.class);
                final String imagingTime = textValueSafe(sceneSource, TAG_SCENE_IMAGING_TIME, String.class);
                final String missionName = textValueSafe(sceneSource, TAG_SCENE_MISSION, String.class);
                final int missionIndex = textValueSafe(sceneSource, TAG_SCENE_MISSION_INDEX, Integer.class);
                final String instrumentName = textValueSafe(sceneSource, TAG_SCENE_INSTRUMENT, String.class);
                final int instrumentIndex = textValueSafe(sceneSource, TAG_SCENE_INSTRUMENT_INDEX, Integer.class);
                final String sensorCode = textValueSafe(sceneSource, TAG_SCENE_SENSOR_CODE, String.class);
                final Double incidenceAngle = textValueSafe(sceneSource, TAG_SCENE_INCIDENCE_ANGLE, Double.class);
                final Double theoreticalResolution = textValueSafe(sceneSource, TAG_SCENE_THEORETICAL_RESOLUTION, Double.class);
                final String viewingAngle = textValueSafe(sceneSource, TAG_SCENE_VIEWING_ANGLE, String.class);
                final Double sunAzimuth = textValueSafe(sceneSource, TAG_SCENE_SUN_AZIMUTH, Double.class);
                final Double sunElevation = textValueSafe(sceneSource, TAG_SCENE_SUN_ELEVATION, Double.class);
                /**
                 * Fills IdentificationInfo
                 */
                // MetaData > IdentificationInfo (DataIdentification) > GraphicOverviews
                final DefaultDataIdentification dataIdentification = (DefaultDataIdentification) getIdentificationInfo(metadata);
                if (thumbnail != null && thumbnail.contains(".")) {
                    dataIdentification.getGraphicOverviews().add(new DefaultBrowseGraphic(generateFileName(name, thumbnail.substring(thumbnail.lastIndexOf(".")))));
                }
                // MetaData > IdentificationInfo (DataIdentification) > supplementalInformation
                if (incidenceAngle != null) {
                    dataIdentification.setSupplementalInformation(new SimpleInternationalString(("incidence angle :" + incidenceAngle)));
                }
                // MetaData > IdentificationInfo (DataIdentification) > Abstract
                dataIdentification.setAbstract(new SimpleInternationalString(missionName + " " + missionIndex + " " + sourceDesc));
                // MetaData > IdentificationInfo (DataIdentification) > Citation
                final DefaultCitation citation = new DefaultCitation();
                final ISODateParser dateParser = new ISODateParser();
                final Date date = dateParser.parseToDate(imagingDate + "T" + imagingTime);
                citation.setDates(Collections.singleton(new DefaultCitationDate(date, DateType.CREATION)));
                citation.setTitle(new SimpleInternationalString(missionName + " " + missionIndex + " " + sourceType + " " + findTypeProduct(missionIndex, sensorCode)));
                dataIdentification.setCitation(citation);
                // MetaData > IdentificationInfo (DataIdentification) > Resolution
                final DefaultResolution resolution = new DefaultResolution();
                resolution.setDistance(findResolution(missionIndex, sensorCode));
                dataIdentification.setSpatialResolutions(Collections.singleton(resolution));
                /**
                 * Fills AcquisitionInfo
                 */
                final DefaultAcquisitionInformation acquisitionInfo = getAcquisitionInfo(metadata);
                // MetaData > AcquisitionInfo > Operations
                final DefaultOperation operation = new DefaultOperation();
                operation.setIdentifier(new DefaultIdentifier(String.valueOf(missionIndex)));
                operation.setDescription(new SimpleInternationalString(missionName));
                acquisitionInfo.getOperations().add(operation);
                // MetaData > AcquisitionInfo > Instruments
                final DefaultInstrument instrument = new DefaultInstrument();
                instrument.setIdentifier(new DefaultIdentifier(instrumentName + instrumentIndex));
                instrument.setDescription(new SimpleInternationalString(instrumentName));
                acquisitionInfo.getInstruments().add(instrument);
                // MetaData > AcquisitionInfo > Platforms
                final DefaultCitation platformCitation = new DefaultCitation();
                platformCitation.setTitle(new SimpleInternationalString(missionName));
                final DefaultPlatform platform = new DefaultPlatform();
                platform.setIdentifier(new DefaultIdentifier(missionName + missionIndex));
                platform.setCitation(platformCitation);
                platform.setDescription(new SimpleInternationalString(missionName + missionIndex));
                acquisitionInfo.getPlatforms().add(platform);
                /**
                 * Fills ContentInfo
                 */
                // MetaData > ContentInfo (ImageDescription) > IlluminationAzimuthAngle AND IlluminationElevationAngle
                final DefaultImageDescription contentInfo = (DefaultImageDescription) getContentInfo(metadata);
                contentInfo.setIlluminationAzimuthAngle(sunAzimuth);
                contentInfo.setIlluminationElevationAngle(sunElevation);
            }
        }
    }
    return metadata;
}
Also used : TypeName(org.opengis.util.TypeName) FactoryException(org.opengis.util.FactoryException) DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) AbstractIdentification(org.apache.sis.metadata.iso.identification.AbstractIdentification) DefaultProcessing(org.apache.sis.metadata.iso.lineage.DefaultProcessing) Element(org.w3c.dom.Element) DomUtilities.firstElement(org.geotoolkit.util.DomUtilities.firstElement) SimpleInternationalString(org.apache.sis.util.SimpleInternationalString) URISyntaxException(java.net.URISyntaxException) DefaultFormat(org.apache.sis.metadata.iso.distribution.DefaultFormat) URI(java.net.URI) DefaultBoundingPolygon(org.apache.sis.metadata.iso.extent.DefaultBoundingPolygon) DefaultLegalConstraints(org.apache.sis.metadata.iso.constraint.DefaultLegalConstraints) DefaultExtent(org.apache.sis.metadata.iso.extent.DefaultExtent) ISODateParser(org.geotoolkit.temporal.object.ISODateParser) DefaultAcquisitionInformation(org.apache.sis.metadata.iso.acquisition.DefaultAcquisitionInformation) DefaultOperation(org.apache.sis.metadata.iso.acquisition.DefaultOperation) DefaultNameFactory(org.apache.sis.util.iso.DefaultNameFactory) DefaultGridSpatialRepresentation(org.apache.sis.metadata.iso.spatial.DefaultGridSpatialRepresentation) DefaultDataIdentification(org.apache.sis.metadata.iso.identification.DefaultDataIdentification) DefaultIdentifier(org.apache.sis.metadata.iso.DefaultIdentifier) DefaultPlatform(org.apache.sis.metadata.iso.acquisition.DefaultPlatform) DefaultProcessStep(org.apache.sis.metadata.iso.lineage.DefaultProcessStep) NoSuchAuthorityCodeException(org.opengis.referencing.NoSuchAuthorityCodeException) DefaultResponsibleParty(org.apache.sis.metadata.iso.citation.DefaultResponsibleParty) DefaultBand(org.apache.sis.metadata.iso.content.DefaultBand) DefaultResolution(org.apache.sis.metadata.iso.identification.DefaultResolution) DefaultAlgorithm(org.apache.sis.metadata.iso.lineage.DefaultAlgorithm) DefaultMetadata(org.apache.sis.metadata.iso.DefaultMetadata) IOException(java.io.IOException) DefaultDimension(org.apache.sis.metadata.iso.spatial.DefaultDimension) SampleDimension(org.apache.sis.coverage.SampleDimension) Dimension(org.opengis.metadata.spatial.Dimension) RangeDimension(org.opengis.metadata.content.RangeDimension) Date(java.util.Date) DefaultCitationDate(org.apache.sis.metadata.iso.citation.DefaultCitationDate) DefaultGeographicDescription(org.apache.sis.metadata.iso.extent.DefaultGeographicDescription) Geometry(org.opengis.geometry.Geometry) Restriction(org.opengis.metadata.constraint.Restriction) DefaultDimension(org.apache.sis.metadata.iso.spatial.DefaultDimension) DefaultImageDescription(org.apache.sis.metadata.iso.content.DefaultImageDescription) SimpleInternationalString(org.apache.sis.util.SimpleInternationalString) MI_Metadata(org.apache.sis.internal.jaxb.gmi.MI_Metadata) MemberName(org.opengis.util.MemberName) DefaultBrowseGraphic(org.apache.sis.metadata.iso.identification.DefaultBrowseGraphic) DefaultCitationDate(org.apache.sis.metadata.iso.citation.DefaultCitationDate) DefaultInstrument(org.apache.sis.metadata.iso.acquisition.DefaultInstrument)

Aggregations

IOException (java.io.IOException)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 Date (java.util.Date)1 SampleDimension (org.apache.sis.coverage.SampleDimension)1 MI_Metadata (org.apache.sis.internal.jaxb.gmi.MI_Metadata)1 DefaultIdentifier (org.apache.sis.metadata.iso.DefaultIdentifier)1 DefaultMetadata (org.apache.sis.metadata.iso.DefaultMetadata)1 DefaultAcquisitionInformation (org.apache.sis.metadata.iso.acquisition.DefaultAcquisitionInformation)1 DefaultInstrument (org.apache.sis.metadata.iso.acquisition.DefaultInstrument)1 DefaultOperation (org.apache.sis.metadata.iso.acquisition.DefaultOperation)1 DefaultPlatform (org.apache.sis.metadata.iso.acquisition.DefaultPlatform)1 DefaultCitation (org.apache.sis.metadata.iso.citation.DefaultCitation)1 DefaultCitationDate (org.apache.sis.metadata.iso.citation.DefaultCitationDate)1 DefaultResponsibleParty (org.apache.sis.metadata.iso.citation.DefaultResponsibleParty)1 DefaultLegalConstraints (org.apache.sis.metadata.iso.constraint.DefaultLegalConstraints)1 DefaultBand (org.apache.sis.metadata.iso.content.DefaultBand)1 DefaultImageDescription (org.apache.sis.metadata.iso.content.DefaultImageDescription)1 DefaultFormat (org.apache.sis.metadata.iso.distribution.DefaultFormat)1 DefaultBoundingPolygon (org.apache.sis.metadata.iso.extent.DefaultBoundingPolygon)1