Search in sources :

Example 1 with DefaultScope

use of org.apache.sis.metadata.iso.quality.DefaultScope in project geotoolkit by Geomatys.

the class CBERS method toMetadata.

/**
 * Extract as much information as possible from CBERS metadata and map it to
 * ISO 19115-2.
 *
 * @param cbersData Metadata
 * @return ISO19115 Metadata
 */
public static Metadata toMetadata(Path cbersData) throws ParserConfigurationException, IOException, SAXException {
    final DefaultMetadata metadata = new DefaultMetadata();
    // Initialisation of DOM document.
    Document doc = DomUtilities.read(cbersData);
    // ////////////////////////////////
    // Data initialisation      //
    // ////////////////////////////////
    // Dom
    final Element root = doc.getDocumentElement();
    Element tmp = null;
    final Element img = DomUtilities.firstElement(doc.getDocumentElement(), "image");
    // metadata
    final DefaultDataIdentification identificationInfo = new DefaultDataIdentification();
    final DefaultGeorectified spatialRep = new DefaultGeorectified();
    final DefaultCitation citation = new DefaultCitation();
    final DefaultResponsibleParty responsibleParty = new DefaultResponsibleParty();
    final DefaultImageDescription contentInfo = new DefaultImageDescription();
    final DefaultDataQuality qualityInfo = new DefaultDataQuality();
    final DefaultLineage lineage = new DefaultLineage();
    final DefaultProcessStep processStep = new DefaultProcessStep();
    final DefaultProcessing processInfo = new DefaultProcessing();
    final DefaultCitation softwareReference = new DefaultCitation();
    final DefaultResponsibleParty processor = new DefaultResponsibleParty();
    final DefaultAcquisitionInformation acquisitionInfo = new DefaultAcquisitionInformation();
    final DefaultInstrument instrument = new DefaultInstrument();
    final DefaultPlatform platform = new DefaultPlatform();
    DefaultMetadata isoData = new DefaultMetadata();
    metadata.getSpatialRepresentationInfo().add(spatialRep);
    metadata.getIdentificationInfo().add(identificationInfo);
    metadata.getDataQualityInfo().add(qualityInfo);
    metadata.getAcquisitionInformation().add(acquisitionInfo);
    qualityInfo.setLineage(lineage);
    lineage.getProcessSteps().add(processStep);
    identificationInfo.setCitation(citation);
    identificationInfo.getPointOfContacts().add(responsibleParty);
    processInfo.getSoftwareReferences().add(softwareReference);
    processStep.setProcessingInformation(processInfo);
    acquisitionInfo.getInstruments().add(instrument);
    acquisitionInfo.getPlatforms().add(platform);
    platform.setCitation(new DefaultCitation("CBERS"));
    // other
    final ISODateParser fp = new ISODateParser();
    // /////////////////////////////////////
    // STEP LISTING            //
    // /////////////////////////////////////
    /**
     * The following comments describe how to fill ISO 19115 metadata from
     * CBERS xml elements. Syntax is : ISO 19115 xml tag to set : CBERS
     * element or default value to use.
     */
    // MI_Metadata/fileIdentifier : FileName
    String fileName = cbersData.getFileName().toString();
    fileName = fileName.substring(0, fileName.lastIndexOf('.'));
    isoData.setFileIdentifier(fileName);
    // MI_Metadata/language : (default value) english
    isoData.setLanguage(Locale.ENGLISH);
    // MI_Metadata/characterSet : (default value) utf8
    isoData.setCharacterSets(Collections.singleton(StandardCharsets.UTF_8));
    // MI_Metadata/dateStamp : get current date
    isoData.setDateStamp(new Date());
    // MI_Metadata/contact/role : (defaultValue) ??
    // MI_Metadata/contact/organisationName :(defaultValue) AGEOS (IRD ???)
    // MI_Metadata/contact/electronicMailAdress : (defaultValue) Institutional e-mail of AGEOS (IRD ??)
    // MI_Metadata/SpatialRepresentationInfo/numberOfDimensions : (defaultValue) 2
    spatialRep.setNumberOfDimensions(2);
    // MI_Metadata/spatialRepresentationInfo/axisDimensionProperties/dimensionName : (defaultValue) row
    final List<Dimension> dims = new ArrayList<Dimension>(2);
    final DefaultDimension dim1 = new DefaultDimension();
    dim1.setDimensionName(DimensionNameType.ROW);
    dims.add(dim1);
    // MI_Metadata/spatialRepresentationInfo/axisDimensionProperties/dimensionName : (defaultValue) column
    final DefaultDimension dim2 = new DefaultDimension();
    dim2.setDimensionName(DimensionNameType.COLUMN);
    dims.add(dim2);
    spatialRep.setAxisDimensionProperties(dims);
    // MI_Metadata/spatialRepresentationInfo/cellGeometry : GeoKeyDirectory.GTRasterTypeGeoKey
    // spatialRep.setCellGeometry(CellGeometry.POINT);
    // MI_Metadata/spatialRepresentationInfo/transformationParameterAvailability : (defaultValue) FALSE
    spatialRep.setTransformationParameterAvailable(false);
    // MI_Metadata/spatialRepresentationInfo/checkPointAvailability : (defaultValue) FALSE
    spatialRep.asMap().put("checkPointAvailability", false);
    isoData.getSpatialRepresentationInfo().add(spatialRep);
    // MI_Metadata/identificationInfo/citation/date/dateType : (defaulValue) Creation
    if (img != null) {
        tmp = DomUtilities.firstElement(img, "timeStamp");
        if (tmp != null) {
            tmp = DomUtilities.firstElement(tmp, "center");
            if (tmp != null) {
                Date centerDate = fp.parseToDate(tmp.getTextContent());
                DefaultCitationDate cDate = new DefaultCitationDate(centerDate, DateType.CREATION);
                citation.getDates().add(cDate);
            }
        }
    }
    // MI_Metadata/identificationInfo/citedResponsibleParty/role : (defaultValue) Originator
    responsibleParty.setRole(Role.ORIGINATOR);
    // MI_Metadata/identificationInfo/resourceConstraints/useConstraints : (defaultValue) otherConstraints
    final Constraints constraint = new DefaultLegalConstraints("otherConstraints");
    identificationInfo.getResourceConstraints().add(constraint);
    // MI_Metadata/identificationInfo/ topicCategory : (defaultValue) imageryBaseMapsEarthCover
    final TopicCategory category = TopicCategory.IMAGERY_BASE_MAPS_EARTH_COVER;
    identificationInfo.getTopicCategories().add(category);
    // MI_Metadata/identificationInfo/extent/geographicElement/geographicIdentifier/code : image/path, image/row
    if (img != null) {
        Element path = DomUtilities.firstElement(img, "path");
        Element row = DomUtilities.firstElement(img, "row");
        if (path != null && row != null) {
            String code = path.getTextContent() + '-' + row.getTextContent();
            DefaultExtent extent = new DefaultExtent();
            extent.getIdentifiers().add(new DefaultIdentifier(code));
            identificationInfo.getExtents().add(extent);
        }
    }
    // MI_Metadata/contentInfo/ attributeDescription : (defaultValue) equivalent radiance (W.m-2.Sr-1.um-1)
    // TODO : not supported
    // MI_Metadata/contentInfo/contentType : (defaultValue) image
    contentInfo.setContentType(CoverageContentType.IMAGE);
    if (img != null) {
        final Element sun = DomUtilities.firstElement(img, "sunPosition");
        if (sun != null) {
            // MI_Metadata/contentInfo/illuminationElevationAngle : image/sunPosition/elevation
            tmp = DomUtilities.firstElement(sun, "elevation");
            if (tmp != null) {
                contentInfo.setIlluminationElevationAngle(Double.valueOf(tmp.getTextContent()));
            }
            // MI_Metadata/contentInfo/illuminationAzimuthAngle : image/sunPosition/sunAzimuth
            tmp = DomUtilities.firstElement(sun, "sunAzimuth");
            if (tmp != null) {
                contentInfo.setIlluminationAzimuthAngle(Double.valueOf(tmp.getTextContent()));
            }
        }
        // MI_Metadata/contentInfo/processingLevelCode/code : image/level
        tmp = DomUtilities.firstElement(img, "level");
        if (tmp != null) {
            contentInfo.setProcessingLevelCode(new DefaultIdentifier(tmp.getTextContent()));
        }
    }
    // contentInfo/dimension/sequenceIdentifier : get BANDx string
    // contentInfo/dimension/descriptor : (defaultValue) BAND1
    final int start = fileName.lastIndexOf("BAND");
    final String band = fileName.substring(start, start + 5);
    final int bandNum = Integer.valueOf(band.substring(band.length() - 1));
    DefaultRangeDimension dim = new DefaultRangeDimension();
    // TODO : set sequence identifier
    dim.setDescriptor(new SimpleInternationalString(band));
    contentInfo.getDimensions().add(dim);
    // contentInfo/dimension/units : (defaultValue) W.m-2.Sr-1.um-1
    // TODO : No equivalent for default value.
    // dataQualityInfo/scope : (defaultValue) dataset
    qualityInfo.setScope(new DefaultScope(ScopeCode.DATASET));
    // dataQualityInfo/lineage/processStep/description: (defaultValue) CBERS LEVEL 2 PRODUCT
    processStep.setDescription(new SimpleInternationalString("CBERS LEVEL 2 PRODUCT"));
    if (img != null) {
        // dataQualityInfo/lineage/processStep/dateTime : image/processingTime
        tmp = DomUtilities.firstElement(img, "processingTime");
        if (tmp != null) {
            final Date resultDate = fp.parseToDate(tmp.getTextContent());
            processStep.setDate(resultDate);
        }
        // dataQualityInfo/lineage/processStep/processor/OrganisationName : image/processingStation
        tmp = DomUtilities.firstElement(img, "processingStation");
        if (tmp != null) {
            processor.setOrganisationName(new SimpleInternationalString(tmp.getTextContent()));
        }
    }
    // dataQualityInfo/lineage/processStep/processor/role : (defaultValue) processor
    processor.setRole(Role.PROCESSOR);
    // dataQualityInfo/lineage/processStep/ processingInformation/softwareReference/title : software
    // dataQualityInfo/lineage/processStep/ processingInformation/softwareReference/edition : version
    tmp = DomUtilities.firstElement(root, "software");
    if (tmp != null) {
        softwareReference.setTitle(new SimpleInternationalString(tmp.getTextContent()));
    }
    if (tmp != null) {
        tmp = DomUtilities.firstElement(root, "version");
    }
    softwareReference.setEdition(new SimpleInternationalString(tmp.getTextContent()));
    // dataQualityInfo/lineage/processStep/ processingInformation/softwareReference/date/date : (defaultValue) NilReason="missing"
    // dataQualityInfo/lineage/processStep/processingInformation/ algorithm/date/date/dateType : (defaultValue) creation
    // TODO : No equivalent for "missing" tag.
    // dataQualityInfo/lineage/processStep/processingInformation/algorithm/description : algorithm/description
    DefaultAlgorithm algo = new DefaultAlgorithm();
    tmp = DomUtilities.firstElement(root, "algorithm");
    if (tmp != null) {
        tmp = DomUtilities.firstElement(tmp, "description");
        if (tmp != null) {
            algo.setDescription(new SimpleInternationalString(tmp.getTextContent()));
        }
    }
    // acquisitionInformation/instrument/type : (defaultValue) Push-broom
    instrument.setType(new SimpleInternationalString("Push-broom"));
    Element sat = DomUtilities.firstElement(root, "Satellite");
    if (sat != null) {
        String platformId = null;
        String cTitle = null;
        tmp = DomUtilities.firstElement(sat, "instrument");
        if (tmp != null) {
            // acquisitionInformation/instrument/identifier : Satellite/instrument
            final String instrumentId = tmp.getTextContent();
            instrument.setIdentifier(new DefaultIdentifier(instrumentId));
            // MI_Metadata/identificationInfo/citation/title : concatenate acquisitionInformation/instrument/identifier and (if id is CCD) PAN or REF
            cTitle = instrumentId;
            if (cTitle.equals("CCD")) {
                if (bandNum < 5) {
                    cTitle += "REF";
                } else {
                    cTitle += "PAN";
                }
            }
            citation.setTitle(new SimpleInternationalString(cTitle));
        }
        final Element name = DomUtilities.firstElement(sat, "name");
        final Element number = DomUtilities.firstElement(sat, "number");
        if (name != null && number != null) {
            // acquisitionInformation/plateform/identifier : Concatenate {Satellite/name} and {Satellite/number}
            // acquisitionInformation/plateform/description : (defaultValue) CBERS_2B
            platformId = name.getTextContent() + '_' + number.getTextContent();
            platform.setIdentifier(new DefaultIdentifier(platformId));
            platform.setDescription(new SimpleInternationalString(platformId));
        }
        if (platformId != null && cTitle != null) {
            // MI_Metadata/IdentificationInfo/abstract : concatenate acquisitionInformation/platform/identifier and identificationInfo/citation/title
            identificationInfo.setAbstract(new SimpleInternationalString(platformId + ' ' + cTitle));
        }
    }
    return metadata;
}
Also used : DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) DefaultProcessing(org.apache.sis.metadata.iso.lineage.DefaultProcessing) DefaultRangeDimension(org.apache.sis.metadata.iso.content.DefaultRangeDimension) Element(org.w3c.dom.Element) ArrayList(java.util.ArrayList) SimpleInternationalString(org.apache.sis.util.SimpleInternationalString) Document(org.w3c.dom.Document) DefaultDataQuality(org.apache.sis.metadata.iso.quality.DefaultDataQuality) DefaultLegalConstraints(org.apache.sis.metadata.iso.constraint.DefaultLegalConstraints) ISODateParser(org.geotoolkit.temporal.object.ISODateParser) DefaultExtent(org.apache.sis.metadata.iso.extent.DefaultExtent) DefaultAcquisitionInformation(org.apache.sis.metadata.iso.acquisition.DefaultAcquisitionInformation) 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) DefaultGeorectified(org.apache.sis.metadata.iso.spatial.DefaultGeorectified) DefaultResponsibleParty(org.apache.sis.metadata.iso.citation.DefaultResponsibleParty) DefaultAlgorithm(org.apache.sis.metadata.iso.lineage.DefaultAlgorithm) DefaultMetadata(org.apache.sis.metadata.iso.DefaultMetadata) DefaultDimension(org.apache.sis.metadata.iso.spatial.DefaultDimension) Dimension(org.opengis.metadata.spatial.Dimension) DefaultRangeDimension(org.apache.sis.metadata.iso.content.DefaultRangeDimension) TopicCategory(org.opengis.metadata.identification.TopicCategory) DefaultScope(org.apache.sis.metadata.iso.quality.DefaultScope) DefaultLineage(org.apache.sis.metadata.iso.lineage.DefaultLineage) Date(java.util.Date) DefaultCitationDate(org.apache.sis.metadata.iso.citation.DefaultCitationDate) DefaultDimension(org.apache.sis.metadata.iso.spatial.DefaultDimension) DefaultImageDescription(org.apache.sis.metadata.iso.content.DefaultImageDescription) Constraints(org.opengis.metadata.constraint.Constraints) DefaultLegalConstraints(org.apache.sis.metadata.iso.constraint.DefaultLegalConstraints) SimpleInternationalString(org.apache.sis.util.SimpleInternationalString) DefaultInstrument(org.apache.sis.metadata.iso.acquisition.DefaultInstrument) DefaultCitationDate(org.apache.sis.metadata.iso.citation.DefaultCitationDate)

Example 2 with DefaultScope

use of org.apache.sis.metadata.iso.quality.DefaultScope in project geotoolkit by Geomatys.

the class LandSat method toMetadata.

/**
 * Extract as much information from the landsat metadata and map it to
 * ISO 19115-2.
 *
 * @param LandSat Metadata
 * @return ISO19115 Metadata
 */
public static Metadata toMetadata(LandSatMetaNode landsat, final String fileName) {
    final DefaultMetadata metadata = new DefaultMetadata();
    // Default values
    metadata.setCharacterSets(Collections.singleton(StandardCharsets.UTF_8));
    metadata.setLanguage(Locale.ENGLISH);
    metadata.setDateStamp(new Date());
    LandSatMetaNode node1;
    LandSatMetaNode node2;
    LandSatMetaNode node3;
    final DefaultGeorectified spatialRepresentation = new DefaultGeorectified();
    metadata.getSpatialRepresentationInfo().add(spatialRepresentation);
    final DefaultDataIdentification identificationInfo = new DefaultDataIdentification();
    metadata.getIdentificationInfo().add(identificationInfo);
    final DefaultAcquisitionInformation aquisitionInfo = new DefaultAcquisitionInformation();
    metadata.getAcquisitionInformation().add(aquisitionInfo);
    final DefaultImageDescription contentInfo = new DefaultImageDescription();
    metadata.getContentInfo().add(contentInfo);
    final DefaultDataQuality qualityInfo = new DefaultDataQuality();
    metadata.getDataQualityInfo().add(qualityInfo);
    final DefaultLineage lineage = new DefaultLineage();
    qualityInfo.setLineage(lineage);
    final DefaultProcessStep processStep = new DefaultProcessStep();
    lineage.getProcessSteps().add(processStep);
    // Landsat : L1_METADATA_FILE/PRODUCT_METADATA/PRODUCT_TYPE
    // iso : MI_Metadata/spatialRepresentationInfo/checkPointAvailability
    // if PRODUCT_TYPE = «  L1T  » then checkPointAvailability = true, otherwise false
    node1 = landsat.search("L1_METADATA_FILE", "PRODUCT_METADATA", "PRODUCT_TYPE");
    if (node1 != null) {
        spatialRepresentation.setCheckPointAvailable("L1T".equalsIgnoreCase(node1.getValue()));
    }
    // build title from band type, example : ETM+ REF
    // [acquisitionInformation/instrument/identifier] PAN
    // [acquisitionInformation/instrument/identifier] REF
    // [acquisitionInformation/instrument/identifier] THM
    // PAN = panchromatic : B80
    // REF = reflective : B10,B20,B30,B40,B50,B70
    // THM = thermal : B61,B62
    // 
    // landsat : L1_METADATA_FILE/PRODUCT_METADATA/SENSOR_ID + type
    // iso : MI_Metadata/identificationInfo/citation/title
    node1 = landsat.search("L1_METADATA_FILE", "PRODUCT_METADATA", "SENSOR_ID");
    if (node1 != null) {
        String title = node1.getValue();
        if (fileName != null) {
            if (fileName.contains("B80")) {
                title += " PAN";
            } else if (fileName.contains("B61") || fileName.contains("B62")) {
                title += " THM";
            } else if (fileName.contains("RGB") || fileName.contains("B10") || fileName.contains("B20") || fileName.contains("B30") || fileName.contains("B40") || fileName.contains("B50") || fileName.contains("B70")) {
                title += " REF";
            }
        }
        DefaultCitation citation = (DefaultCitation) identificationInfo.getCitation();
        if (citation == null) {
            citation = new DefaultCitation();
            identificationInfo.setCitation(citation);
        }
        citation.setTitle(new SimpleInternationalString(title));
    }
    // Landsat :  L1_METADATA_FILE/PRODUCT_METADATA/ACQUISITION_DATE + SCENE_CENTER_SCAN_TIME
    // iso : MI_Metadata/identificationInfo/citation/date/date
    // iso : MI_Metadata/identificationInfo/citation/date/dateType value=creation
    node1 = landsat.search("L1_METADATA_FILE", "PRODUCT_METADATA", "ACQUISITION_DATE");
    node2 = landsat.search("L1_METADATA_FILE", "PRODUCT_METADATA", "SCENE_CENTER_SCAN_TIME");
    if (node1 != null && node2 != null) {
        DefaultCitation citation = (DefaultCitation) identificationInfo.getCitation();
        if (citation == null) {
            citation = new DefaultCitation();
            identificationInfo.setCitation(citation);
        }
        final String strdate = node1.getValue() + "T" + node2.getValue();
        final ISODateParser fp = new ISODateParser();
        final java.util.Date resultDate = fp.parseToDate(strdate);
        final CitationDate date = new DefaultCitationDate(resultDate, DateType.CREATION);
        citation.getDates().add(date);
    }
    // Landsat : L1_METADATA_FILE/METADATA_FILE_INFO/ORIGIN
    // iso : MI_Metadata/identificationInfo/citedResponsibleParty/organisationName
    // iso : MI_Metadata/identificationInfo/citedResponsibleParty/role value=originator
    node1 = landsat.search("L1_METADATA_FILE", "METADATA_FILE_INFO", "ORIGIN");
    if (node1 != null) {
        final DefaultResponsibleParty responsibleParty = new DefaultResponsibleParty();
        responsibleParty.setOrganisationName(new SimpleInternationalString(node1.getValue()));
        responsibleParty.setRole(Role.ORIGINATOR);
        identificationInfo.getPointOfContacts().add(responsibleParty);
    }
    // Landsat : L1_METADATA_FILE/PRODUCT_METADATA/SENSOR_ID
    // iso : acquisitionInformation/instrument/identifier
    // iso : acquisitionInformation/instrument/type  value=Push-broom
    node1 = landsat.search("L1_METADATA_FILE", "PRODUCT_METADATA", "SENSOR_ID");
    if (node1 != null) {
        final DefaultInstrument instrument = new DefaultInstrument();
        aquisitionInfo.getInstruments().add(instrument);
        instrument.setIdentifier(new DefaultIdentifier(node1.getValue()));
        instrument.setType(new SimpleInternationalString("Push-broom"));
    }
    // Landsat : L1_METADATA_FILE/PRODUCT_METADATA/SPACECRAFT_ID
    // iso : acquisitionInformation/platform/identifier
    // iso : acquisitionInformation/platform/description
    node1 = landsat.search("L1_METADATA_FILE", "PRODUCT_METADATA", "SPACECRAFT_ID");
    if (node1 != null) {
        final DefaultPlatform platform = new DefaultPlatform();
        aquisitionInfo.getPlatforms().add(platform);
        platform.setIdentifier(new DefaultIdentifier(node1.getValue()));
        platform.setDescription(new SimpleInternationalString(node1.getValue()));
        platform.setCitation(new DefaultCitation(node1.getValue()));
    }
    // iso : MI_Metadata/identificationInfo/abstract
    // concatenate [acquisitionInformation/platform/identifier] et [MI_Metadata/identificationInfo/citation/title]
    String abs = "";
    if (!aquisitionInfo.getPlatforms().isEmpty()) {
        abs += aquisitionInfo.getPlatforms().iterator().next().getIdentifier().toString();
    }
    if (identificationInfo.getCitation() != null) {
        abs += " " + identificationInfo.getCitation().getTitle();
    }
    identificationInfo.setAbstract(new SimpleInternationalString(abs));
    // iso : MI_Metadata/identificationInfo/resourceFormat/name  value=geotiff
    final DefaultFormat format = new DefaultFormat();
    format.setName(new SimpleInternationalString("geotiff"));
    identificationInfo.getResourceFormats().add(format);
    // iso : MI_Metadata/identificationInfo/resourceConstraints/useConstraints  value=otherConstraints
    final Constraints constraint = new DefaultLegalConstraints("otherConstraints");
    identificationInfo.getResourceConstraints().add(constraint);
    // iso : MI_Metadata/identificationInfo/topicCategory  value=imageryBaseMapsEarthCover
    final TopicCategory category = TopicCategory.IMAGERY_BASE_MAPS_EARTH_COVER;
    identificationInfo.getTopicCategories().add(category);
    // Landsat : L1_METADATA_FILE/PRODUCT_METADATA/WRS_PATH + STARTING_ROW + ENDING_ROW
    // iso : MI_Metadata/identificationInfo/extent/geographicElement/geographicIdentifier/code
    // Concatenate path + starting row with format «  ppp_rrr  ».
    node1 = landsat.search("L1_METADATA_FILE", "PRODUCT_METADATA", "WRS_PATH");
    node2 = landsat.search("L1_METADATA_FILE", "PRODUCT_METADATA", "STARTING_ROW");
    if (node1 != null && node2 != null) {
        final DefaultExtent extent = new DefaultExtent();
        extent.getIdentifiers().add(new DefaultIdentifier(node1.getValue() + "_" + node2.getValue()));
        identificationInfo.getExtents().add(extent);
    }
    // iso : MI_Metadata/contentInfo/attributeDescription  value=equivalent radiance (W.m-2.Sr-1.um-1)
    // TODO : not supported
    // iso : MI_Metadata/contentInfo/contentType  value=image
    contentInfo.setContentType(CoverageContentType.IMAGE);
    // Landsat : L1_METADATA_FILE/PRODUCT_PARAMETERS/SUN_ELEVATION
    // iso : MI_Metadata/contentInfo/illuminationElevationAngle
    node1 = landsat.search("L1_METADATA_FILE", "PRODUCT_PARAMETERS", "SUN_ELEVATION");
    if (node1 != null) {
        contentInfo.setIlluminationElevationAngle(tryDouble(node1.getValue()));
    }
    // Landsat : L1_METADATA_FILE/PRODUCT_PARAMETERS/SUN_AZIMUTH
    // iso : MI_Metadata/contentInfo/illuminationAzimuthAngle
    node1 = landsat.search("L1_METADATA_FILE", "PRODUCT_PARAMETERS", "SUN_AZIMUTH");
    if (node1 != null) {
        contentInfo.setIlluminationAzimuthAngle(tryDouble(node1.getValue()));
    }
    // Landsat : L1_METADATA_FILE/PRODUCT_METADATA/PRODUCT_TYPE
    // iso : MI_Metadata/contentInfo/processingLevelCode/code
    node1 = landsat.search("L1_METADATA_FILE", "PRODUCT_METADATA", "PRODUCT_TYPE");
    if (node1 != null) {
        contentInfo.setProcessingLevelCode(new DefaultIdentifier(node1.getValue()));
    }
    // iso : contentInfo/dimension/sequenceIdentifier
    // iso : contentInfo/dimension/descriptor  value=BAND1
    // One occurrence of contentInfo/dimension/ for each spectral band.
    // loop on BAND  ?_FILE_NAME ou BAND  ??_FILE_NAME  trouvés dans le fichier MTL.txt.
    // example  :
    // BAND1, ,BAND2, BAND3, BAND4, BAND5, BAND61, BAND62, BAND7, BAND8  in case of L7 ETM+
    // BAND1, ,BAND2, BAND3, BAND4, BAND5, BAND6, BAND7 in case of L4 et L5 TM
    // BAND4, BAND5, BAND6, BAND7 in case of MSS
    // TODO filled later, depending on band merged operation this is different
    // Landsat : L1_METADATA_FILE/MIN_MAX_PIXEL_VALUE/QCALMIN_BAND1
    // iso : contentInfo/dimension/minValue
    // Caution, there is one value for each band.
    // So we have to link the value to the correct band.
    // elements BAND  ?? and BAND  ??_FILE_NAME allows to do it.
    // TODO filled later, depending on band merged operation this is different
    // Landsat : L1_METADATA_FILE/MIN_MAX_PIXEL_VALUE/QCALMAX_BAND1
    // iso : contentInfo/dimension/maxValue
    // same as above
    // TODO filled later, depending on band merged operation this is different
    // iso : contentInfo/dimension/units  value=W.m-2.Sr-1.um-1
    // TODO filled later, depending on band merged operation this is different
    // Landsat : L1_METADATA_FILE/MIN_MAX_RADIANCE/LMAX_BAND1 + LMIN_BAND1
    // Landsat : L1_METADATA_FILE/MIN_MAX_PIXEL_VALUE/QCALMAX_BAND1 + QCALMIN_BAND1
    // iso : contentInfo/dimension/scaleFactor
    // calculate : scaleFactor = (LMAX_BAND1 -  LMIN_BAND1) / (QCALMAX_BAND1 – QCALMIN_BAND1)
    // TODO ???
    // Landsat : L1_METADATA_FILE/MIN_MAX_RADIANCE/LMIN_BAND5
    // iso : contentInfo/dimension/offset
    // same as above
    // TODO ???
    // iso : dataQualityInfo/scope  value=dataset
    qualityInfo.setScope(new DefaultScope(ScopeCode.DATASET));
    // iso : dataQualityInfo/lineage/processStep/description  value=LANDSAT LEVEL 1 PRODUCT
    processStep.setDescription(new SimpleInternationalString("LANDSAT LEVEL 1 PRODUCT"));
    // Landsat : L1_METADATA_FILE/METADATA_FILE_INFO/PRODUCT_CREATION_TIME
    // iso : dataQualityInfo/lineage/processStep/dateTime
    node1 = landsat.search("L1_METADATA_FILE", "METADATA_FILE_INFO", "PRODUCT_CREATION_TIME");
    if (node1 != null) {
        final ISODateParser fp = new ISODateParser();
        final java.util.Date resultDate = fp.parseToDate(node1.getValue());
        processStep.setDate(resultDate);
    }
    // iso : dataQualityInfo/lineage/processStep/processor/OrganisationName  value=USGS
    // iso : dataQualityInfo/lineage/processStep/processor/role  value=processor
    final DefaultResponsibleParty processor = new DefaultResponsibleParty();
    processor.setOrganisationName(new SimpleInternationalString("USGS"));
    processor.setRole(Role.PROCESSOR);
    processStep.getProcessors().add(processor);
    // Landsat : L1_METADATA_FILE/METADATA_FILE_ INFO/REQUEST_ID
    // iso : dataQualityInfo/lineage/processStep/processingInformation/identifier/code
    final DefaultProcessing processInfo = new DefaultProcessing();
    processStep.setProcessingInformation(processInfo);
    node1 = landsat.search("L1_METADATA_FILE", "METADATA_FILE_INFO", "REQUEST_ID");
    if (node1 != null) {
        processInfo.setIdentifier(new DefaultIdentifier(node1.getValue()));
    }
    // Landsat : L1_METADATA_FILE/PRODUCT_METADATA/PROCESSING_SOFTWARE
    // iso : dataQualityInfo/lineage/processStep/processingInformation/softwareReference/title
    // iso : dataQualityInfo/lineage/processStep/processingInformation/softwareReference/edition
    final DefaultCitation softwareReference = new DefaultCitation();
    processInfo.getSoftwareReferences().add(softwareReference);
    node1 = landsat.search("L1_METADATA_FILE", "PRODUCT_METADATA", "PROCESSING_SOFTWARE");
    if (node1 != null) {
        softwareReference.setTitle(new SimpleInternationalString(node1.getValue()));
        softwareReference.setEdition(new SimpleInternationalString(node1.getValue()));
    }
    return metadata;
}
Also used : DefaultCitation(org.apache.sis.metadata.iso.citation.DefaultCitation) Date(java.util.Date) DefaultProcessing(org.apache.sis.metadata.iso.lineage.DefaultProcessing) SimpleInternationalString(org.apache.sis.util.SimpleInternationalString) DefaultFormat(org.apache.sis.metadata.iso.distribution.DefaultFormat) DefaultDataQuality(org.apache.sis.metadata.iso.quality.DefaultDataQuality) DefaultLegalConstraints(org.apache.sis.metadata.iso.constraint.DefaultLegalConstraints) ISODateParser(org.geotoolkit.temporal.object.ISODateParser) DefaultExtent(org.apache.sis.metadata.iso.extent.DefaultExtent) DefaultAcquisitionInformation(org.apache.sis.metadata.iso.acquisition.DefaultAcquisitionInformation) DefaultDataIdentification(org.apache.sis.metadata.iso.identification.DefaultDataIdentification) CitationDate(org.opengis.metadata.citation.CitationDate) DefaultCitationDate(org.apache.sis.metadata.iso.citation.DefaultCitationDate) DefaultIdentifier(org.apache.sis.metadata.iso.DefaultIdentifier) DefaultPlatform(org.apache.sis.metadata.iso.acquisition.DefaultPlatform) DefaultProcessStep(org.apache.sis.metadata.iso.lineage.DefaultProcessStep) DefaultGeorectified(org.apache.sis.metadata.iso.spatial.DefaultGeorectified) DefaultResponsibleParty(org.apache.sis.metadata.iso.citation.DefaultResponsibleParty) DefaultMetadata(org.apache.sis.metadata.iso.DefaultMetadata) TopicCategory(org.opengis.metadata.identification.TopicCategory) DefaultScope(org.apache.sis.metadata.iso.quality.DefaultScope) DefaultLineage(org.apache.sis.metadata.iso.lineage.DefaultLineage) Date(java.util.Date) CitationDate(org.opengis.metadata.citation.CitationDate) DefaultCitationDate(org.apache.sis.metadata.iso.citation.DefaultCitationDate) DefaultImageDescription(org.apache.sis.metadata.iso.content.DefaultImageDescription) Constraints(org.opengis.metadata.constraint.Constraints) DefaultLegalConstraints(org.apache.sis.metadata.iso.constraint.DefaultLegalConstraints) SimpleInternationalString(org.apache.sis.util.SimpleInternationalString) DefaultCitationDate(org.apache.sis.metadata.iso.citation.DefaultCitationDate) DefaultInstrument(org.apache.sis.metadata.iso.acquisition.DefaultInstrument)

Aggregations

Date (java.util.Date)2 DefaultIdentifier (org.apache.sis.metadata.iso.DefaultIdentifier)2 DefaultMetadata (org.apache.sis.metadata.iso.DefaultMetadata)2 DefaultAcquisitionInformation (org.apache.sis.metadata.iso.acquisition.DefaultAcquisitionInformation)2 DefaultInstrument (org.apache.sis.metadata.iso.acquisition.DefaultInstrument)2 DefaultPlatform (org.apache.sis.metadata.iso.acquisition.DefaultPlatform)2 DefaultCitation (org.apache.sis.metadata.iso.citation.DefaultCitation)2 DefaultCitationDate (org.apache.sis.metadata.iso.citation.DefaultCitationDate)2 DefaultResponsibleParty (org.apache.sis.metadata.iso.citation.DefaultResponsibleParty)2 DefaultLegalConstraints (org.apache.sis.metadata.iso.constraint.DefaultLegalConstraints)2 DefaultImageDescription (org.apache.sis.metadata.iso.content.DefaultImageDescription)2 DefaultExtent (org.apache.sis.metadata.iso.extent.DefaultExtent)2 DefaultDataIdentification (org.apache.sis.metadata.iso.identification.DefaultDataIdentification)2 DefaultLineage (org.apache.sis.metadata.iso.lineage.DefaultLineage)2 DefaultProcessStep (org.apache.sis.metadata.iso.lineage.DefaultProcessStep)2 DefaultProcessing (org.apache.sis.metadata.iso.lineage.DefaultProcessing)2 DefaultDataQuality (org.apache.sis.metadata.iso.quality.DefaultDataQuality)2 DefaultScope (org.apache.sis.metadata.iso.quality.DefaultScope)2 DefaultGeorectified (org.apache.sis.metadata.iso.spatial.DefaultGeorectified)2 SimpleInternationalString (org.apache.sis.util.SimpleInternationalString)2