示例#1
0
        public static MD_Metadata_Type CreateMetadataExample()
        {
            MD_Metadata_Type m = new MD_Metadata_Type();

            m.fileIdentifier          = CharString("12345-67890-aabbcc-ddeeff-ggffhhjj");
            m.language                = CharString("nor");
            m.metadataStandardName    = CharString("ISO19139");
            m.metadataStandardVersion = CharString("1.0");
            m.hierarchyLevel          = new[] { new MD_ScopeCode_PropertyType
                                                {
                                                    MD_ScopeCode = new CodeListValue_Type
                                                    {
                                                        codeList      = "http://www.isotc211.org/2005/resources/codeList.xml#MD_ScopeCode",
                                                        codeListValue = "dataset"
                                                    }
                                                } };

            var responsibleParty = new CI_ResponsibleParty_Type()
            {
                individualName = CharString("Hans Hansen"),
                role           = new CI_RoleCode_PropertyType()
                {
                    CI_RoleCode = new CodeListValue_Type
                    {
                        codeList      = "http://www.isotc211.org/2005/resources/codeList.xml#CI_RoleCode",
                        codeListValue = "resourceProvider"
                    }
                },
                organisationName = CharString("Statens Kartverk"),
                contactInfo      = new CI_Contact_PropertyType()
                {
                    CI_Contact = new CI_Contact_Type()
                    {
                        address = new CI_Address_PropertyType()
                        {
                            CI_Address = new CI_Address_Type()
                            {
                                electronicMailAddress = new[] { CharString("*****@*****.**") }
                            }
                        }
                    }
                }
            };

            m.contact = new CI_ResponsibleParty_PropertyType[] { new CI_ResponsibleParty_PropertyType()
                                                                 {
                                                                     CI_ResponsibleParty = responsibleParty
                                                                 } };

            m.dateStamp = new Date_PropertyType()
            {
                Item = DateTime.Now
            };

            var mdDataIdentificationType = new MD_DataIdentification_Type();

            mdDataIdentificationType.pointOfContact = new[] {
                new CI_ResponsibleParty_PropertyType {
                    CI_ResponsibleParty = responsibleParty
                }
            };
            mdDataIdentificationType.citation = new CI_Citation_PropertyType
            {
                CI_Citation = new CI_Citation_Type
                {
                    title = CharString("Eksempeldatasettet sin tittel."),
                    date  = new[] {
                        new CI_Date_PropertyType {
                            CI_Date = new CI_Date_Type {
                                date = new Date_PropertyType {
                                    Item = DateTime.Now.Date.ToString("yyyy-MM-dd")
                                },
                                dateType = new CI_DateTypeCode_PropertyType {
                                    CI_DateTypeCode = new CodeListValue_Type
                                    {
                                        codeList      = "http://www.isotc211.org/2005/resources/codeList.xml#CI_DateTypeCode",
                                        codeListValue = "creation"
                                    }
                                }
                            }
                        }
                    },
                    alternateTitle = new[] { CharString("Dette er en den alternative tittelen til datasettet som tilbys.") },
                    identifier     = new[] { new MD_Identifier_PropertyType
                                             {
                                                 MD_Identifier = new MD_Identifier_Type
                                                 {
                                                     code = CharString("12345-abcdef-67890-ghijkl")
                                                 }
                                             } }
                }
            };
            mdDataIdentificationType.@abstract             = CharString("Dette datasettet inneholder ditt og datt. Kan brukes til dette, men må ikke brukes til andre ting som for eksempel dette.");
            mdDataIdentificationType.purpose               = CharString("Dette er formålet.");
            mdDataIdentificationType.resourceSpecificUsage = new[]
            {
                new MD_Usage_PropertyType()
                {
                    MD_Usage = new MD_Usage_Type()
                    {
                        specificUsage = CharString("Skal bare brukes sånn og sånn"),
                        usageDateTime = new DateTime_PropertyType()
                        {
                            DateTime = DateTime.Now
                        },
                        userContactInfo = new []
                        {
                            new CI_ResponsibleParty_PropertyType
                            {
                                CI_ResponsibleParty = responsibleParty
                            }
                        },
                        userDeterminedLimitations = CharString("Her kommer det begrensninger på bruk av dataene.")
                    }
                }
            };
            mdDataIdentificationType.spatialResolution = new MD_Resolution_PropertyType[] { new MD_Resolution_PropertyType()
                                                                                            {
                                                                                                MD_Resolution = new MD_Resolution_Type()
                                                                                                {
                                                                                                    Item = new MD_RepresentativeFraction_PropertyType()
                                                                                                    {
                                                                                                        MD_RepresentativeFraction = new MD_RepresentativeFraction_Type()
                                                                                                        {
                                                                                                            denominator = new Integer_PropertyType()
                                                                                                            {
                                                                                                                Integer = "1000"
                                                                                                            }
                                                                                                        }
                                                                                                    }
                                                                                                }
                                                                                            } };
            mdDataIdentificationType.language            = new[] { CharString("nor") };
            mdDataIdentificationType.descriptiveKeywords = new[] {
                new MD_Keywords_PropertyType {
                    MD_Keywords = new MD_Keywords_Type {
                        keyword = new CharacterString_PropertyType[]
                        {
                            new PT_FreeText_PropertyType
                            {
                                CharacterString = "Adresser",
                                PT_FreeText     = new PT_FreeText_Type {
                                    id        = "ENG",
                                    textGroup = new LocalisedCharacterString_PropertyType[]
                                    {
                                        new LocalisedCharacterString_PropertyType {
                                            LocalisedCharacterString = new LocalisedCharacterString_Type
                                            {
                                                locale = "#ENG",
                                                Value  = "Addresses"
                                            }
                                        }
                                    }
                                }
                            }
                        },
                        thesaurusName = new CI_Citation_PropertyType
                        {
                            CI_Citation = new CI_Citation_Type
                            {
                                title = CharString("GEMET - INSPIRE themes, version 1.0"),

                                date = new [] { new CI_Date_PropertyType
                                                {
                                                    CI_Date = new CI_Date_Type
                                                    {
                                                        date = new Date_PropertyType {
                                                            Item = DateTime.Now
                                                        },
                                                        dateType = new CI_DateTypeCode_PropertyType
                                                        {
                                                            CI_DateTypeCode = new CodeListValue_Type()
                                                            {
                                                                codeList      = "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode",
                                                                codeListValue = "publication"
                                                            }
                                                        }
                                                    }
                                                } }
                            }
                        }
                    }
                }
            };
            mdDataIdentificationType.resourceConstraints = new[]
            {
                new MD_Constraints_PropertyType
                {
                    MD_Constraints = new MD_Constraints_Type
                    {
                        useLimitation = new [] { CharString("Gratis å benytte til alle formål.") }
                    }
                },
                new MD_Constraints_PropertyType
                {
                    MD_Constraints = new MD_LegalConstraints_Type
                    {
                        accessConstraints = new MD_RestrictionCode_PropertyType[]
                        {
                            new MD_RestrictionCode_PropertyType
                            {
                                MD_RestrictionCode = new CodeListValue_Type {
                                    codeListValue = "none", codeList = "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/gmxCodelists.xml#MD_RestrictionCode"
                                }
                            }
                        },
                        useConstraints = new MD_RestrictionCode_PropertyType[]
                        {
                            new MD_RestrictionCode_PropertyType
                            {
                                MD_RestrictionCode = new CodeListValue_Type {
                                    codeListValue = "free", codeList = "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/gmxCodelists.xml#MD_RestrictionCode"
                                }
                            }
                        },
                        otherConstraints = new MD_RestrictionOther_PropertyType [] { new MD_RestrictionOther_PropertyType {
                                                                                         MD_RestrictionOther = CharString("Ingen begrensninger på bruk.")
                                                                                     }, new MD_RestrictionOther_PropertyType {
                                                                                         MD_RestrictionOther = new Anchor_Type {
                                                                                             href = "http://test.no", Value = "Link"
                                                                                         }
                                                                                     } }
                    }
                },
                new MD_Constraints_PropertyType
                {
                    MD_Constraints = new MD_SecurityConstraints_Type
                    {
                        userNote = new CharacterString_PropertyType
                        {
                            CharacterString = "Text that describes why it is not freely open"
                        },
                        classification = new MD_ClassificationCode_PropertyType
                        {
                            MD_ClassificationCode = new CodeListValue_Type
                            {
                                codeList      = "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/codelist/gmxCodelists.xml#MD_ClassificationCode",
                                codeListValue = "unclassified"
                            }
                        }
                    }
                }
            };
            mdDataIdentificationType.topicCategory = new[] { new MD_TopicCategoryCode_PropertyType
                                                             {
                                                                 MD_TopicCategoryCode = MD_TopicCategoryCode_Type.location
                                                             } };
            mdDataIdentificationType.extent = new[]
            {
                new EX_Extent_PropertyType
                {
                    EX_Extent = new EX_Extent_Type
                    {
                        geographicElement = new []
                        {
                            new EX_GeographicExtent_PropertyType
                            {
                                AbstractEX_GeographicExtent = new EX_GeographicBoundingBox_Type
                                {
                                    westBoundLongitude = new Decimal_PropertyType {
                                        Decimal = 2
                                    },
                                    eastBoundLongitude = new Decimal_PropertyType {
                                        Decimal = 33
                                    },
                                    southBoundLatitude = new Decimal_PropertyType {
                                        Decimal = 57
                                    },
                                    northBoundLatitude = new Decimal_PropertyType {
                                        Decimal = 72
                                    }
                                }
                            }
                        },
                        temporalElement = new EX_TemporalExtent_PropertyType[]
                        {
                            new EX_TemporalExtent_PropertyType
                            {
                                EX_TemporalExtent = new EX_TemporalExtent_Type
                                {
                                    extent = new TM_Primitive_PropertyType
                                    {
                                        AbstractTimePrimitive = new TimePeriodType()
                                        {
                                            id = "id_1",

                                            Item = new TimePositionType()
                                            {
                                                Value = "2014-01-01"
                                            },
                                            Item1 = new TimePositionType()
                                            {
                                                Value = "2020-01-01"
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            };

            mdDataIdentificationType.supplementalInformation = CharString("Dette er den utfyllende informasjonen.");

            m.identificationInfo = new[] {
                new MD_Identification_PropertyType
                {
                    AbstractMD_Identification = mdDataIdentificationType
                }
            };


            m.distributionInfo = new MD_Distribution_PropertyType
            {
                MD_Distribution = new MD_Distribution_Type
                {
                    transferOptions = new[]
                    {
                        new MD_DigitalTransferOptions_PropertyType
                        {
                            MD_DigitalTransferOptions = new MD_DigitalTransferOptions_Type
                            {
                                onLine = new[]
                                {
                                    new CI_OnlineResource_PropertyType
                                    {
                                        CI_OnlineResource = new CI_OnlineResource_Type
                                        {
                                            linkage = new URL_PropertyType
                                            {
                                                URL = "http://www.kartverket.no"
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            };

            var dqDataQualityType = new DQ_DataQuality_Type();

            dqDataQualityType.scope = new DQ_Scope_PropertyType
            {
                DQ_Scope = new DQ_Scope_Type
                {
                    level = new MD_ScopeCode_PropertyType
                    {
                        MD_ScopeCode = new CodeListValue_Type
                        {
                            codeList      = "http://www.isotc211.org/2005/resources/codeList.xml#MD_ScopeCode",
                            codeListValue = "dataset"
                        }
                    }
                }
            };
            dqDataQualityType.lineage = new LI_Lineage_PropertyType
            {
                LI_Lineage = new LI_Lineage_Type
                {
                    statement = CharString("Her kommer det en tekst om prosesshistorien.")
                }
            };
            dqDataQualityType.report = new[]
            {
                new DQ_Element_PropertyType
                {
                    AbstractDQ_Element = new DQ_DomainConsistency_Type
                    {
                        result = new [] {
                            new DQ_Result_PropertyType
                            {
                                AbstractDQ_Result = new DQ_ConformanceResult_Type
                                {
                                    specification = new CI_Citation_PropertyType
                                    {
                                        CI_Citation = new CI_Citation_Type
                                        {
                                            title = CharString("COMMISSION REGULATION (EU) No 1089/2010 of 23 November 2010 implementing Directive 2007/2/EC of the European Parliament and of the Council as regards interoperability of spatial data sets and services"),
                                            date  = new CI_Date_PropertyType[]
                                            {
                                                new CI_Date_PropertyType
                                                {
                                                    CI_Date = new CI_Date_Type
                                                    {
                                                        date = new Date_PropertyType
                                                        {
                                                            Item = "2010-12-08"
                                                        },
                                                        dateType = new CI_DateTypeCode_PropertyType
                                                        {
                                                            CI_DateTypeCode = new CodeListValue_Type
                                                            {
                                                                codeList      = "http://standards.iso.org/ittf/PubliclyAvailableStandards/ISO_19139_Schemas/resources/Codelist/ML_gmxCodelists.xml#CI_DateTypeCode",
                                                                codeListValue = "publication"
                                                            }
                                                        }
                                                    }
                                                }
                                            }
                                        }
                                    },
                                    explanation = CharString("See the referenced specification"),
                                    pass        = new Boolean_PropertyType {
                                        Boolean = true
                                    }
                                }
                            }
                        }
                    }
                }
            };

            m.dataQualityInfo = new[] { new DQ_DataQuality_PropertyType {
                                            DQ_DataQuality = dqDataQualityType
                                        } };

            m.referenceSystemInfo = new MD_ReferenceSystem_PropertyType[]
            {
                new MD_ReferenceSystem_PropertyType
                {
                    MD_ReferenceSystem = new MD_ReferenceSystem_Type
                    {
                        referenceSystemIdentifier = new RS_Identifier_PropertyType
                        {
                            RS_Identifier = new RS_Identifier_Type
                            {
                                code = new CharacterString_PropertyType
                                {
                                    CharacterString = "http://www.opengis.net/def/crs/EPSG/0/25831"
                                },
                                codeSpace = new CharacterString_PropertyType
                                {
                                    CharacterString = "EPSG"
                                }
                            }
                        }
                    }
                }
            };

            return(m);
        }
示例#2
0
        private MetadataEntry ParseCswRecordResponse(string uuid, MD_Metadata_Type metadata)
        {
            var    title           = "unknown";
            var    resourceType    = "unknown";
            var    organization    = "unknown";
            var    inspireResource = false;
            string purpose         = null;
            string abstractText    = null;

            StringBuilder contactInformation = new StringBuilder();

            List <string> keywords = new List <string>();

            if (metadata != null)
            {
                if (metadata.hierarchyLevel != null && metadata.hierarchyLevel[0] != null)
                {
                    resourceType = metadata.hierarchyLevel[0].MD_ScopeCode.codeListValue;
                }

                var dataIdentification = metadata.identificationInfo[0].AbstractMD_Identification;
                if (dataIdentification != null)
                {
                    CharacterString_PropertyType titleString = null;

                    Anchor_Type titleObject = dataIdentification.citation.CI_Citation.title.item as Anchor_Type;
                    if (titleObject != null)
                    {
                        titleString = toCharString(titleObject.Value);
                    }
                    else
                    {
                        titleString = dataIdentification.citation.CI_Citation.title.item as CharacterString_PropertyType;
                    }

                    title = titleString.CharacterString;

                    if (dataIdentification.pointOfContact != null &&
                        dataIdentification.pointOfContact[0] != null &&
                        dataIdentification.pointOfContact[0].CI_ResponsibleParty != null)
                    {
                        CI_ResponsibleParty_Type responsibleParty = dataIdentification.pointOfContact[0].CI_ResponsibleParty;

                        if (responsibleParty.organisationName != null && !string.IsNullOrWhiteSpace(responsibleParty.organisationName.CharacterString))
                        {
                            organization = responsibleParty.organisationName.CharacterString;
                        }

                        if (responsibleParty.individualName != null &&
                            !string.IsNullOrWhiteSpace(responsibleParty.individualName.CharacterString))
                        {
                            contactInformation.Append(responsibleParty.individualName.CharacterString);
                        }

                        if (responsibleParty.contactInfo != null && responsibleParty.contactInfo.CI_Contact != null)
                        {
                            var contact = responsibleParty.contactInfo.CI_Contact;


                            if (contact.address != null && contact.address.CI_Address != null)
                            {
                                var address = contact.address.CI_Address;
                                if (address.electronicMailAddress != null && address.electronicMailAddress[0] != null &&
                                    !string.IsNullOrWhiteSpace(address.electronicMailAddress[0].CharacterString))
                                {
                                    contactInformation.Append(" - ").Append(address.electronicMailAddress[0].CharacterString).Append("\n");
                                }
                                else
                                {
                                    contactInformation.Append("\n");
                                }


                                if (address.deliveryPoint != null && address.deliveryPoint[0] != null &&
                                    !string.IsNullOrWhiteSpace(address.deliveryPoint[0].CharacterString))
                                {
                                    contactInformation.Append(address.deliveryPoint[0].CharacterString).Append(", ");
                                }

                                if (address.postalCode != null && !string.IsNullOrWhiteSpace(address.postalCode.CharacterString))
                                {
                                    contactInformation.Append(address.postalCode.CharacterString).Append(" ");
                                }

                                if (address.city != null && !string.IsNullOrWhiteSpace(address.city.CharacterString))
                                {
                                    contactInformation.Append(address.city.CharacterString);
                                }
                            }



                            if (contact.phone != null && contact.phone.CI_Telephone != null &&
                                contact.phone.CI_Telephone.voice != null && contact.phone.CI_Telephone.voice[0] != null &&
                                !string.IsNullOrWhiteSpace(contact.phone.CI_Telephone.voice[0].CharacterString))
                            {
                                contactInformation.Append("\nTlf: ").Append(contact.phone.CI_Telephone.voice[0].CharacterString);
                            }
                        }
                    }


                    // collect keywords
                    if (dataIdentification.descriptiveKeywords != null)
                    {
                        foreach (var descriptiveKeyword in dataIdentification.descriptiveKeywords)
                        {
                            if (descriptiveKeyword.MD_Keywords != null && descriptiveKeyword.MD_Keywords.keyword != null)
                            {
                                foreach (var singleKeyword in descriptiveKeyword.MD_Keywords.keyword)
                                {
                                    if (singleKeyword.keyword != null)
                                    {
                                        string keywordValue = GetStringOrNull(singleKeyword);

                                        keywords.Add(keywordValue);

                                        /** old way of determine inspire or norge digitalt
                                         * if (singleKeyword.CharacterString.Equals("annet", StringComparison.InvariantCultureIgnoreCase))
                                         * {
                                         *  inspireResource = false;
                                         * }
                                         **/
                                    }
                                }
                            }
                        }
                    }


                    inspireResource = IsInspireResource(metadata);

                    // collect purpose

                    if (dataIdentification.purpose != null && !string.IsNullOrWhiteSpace(dataIdentification.purpose.CharacterString))
                    {
                        purpose = dataIdentification.purpose.CharacterString;
                    }


                    // collect abstract

                    if (dataIdentification.@abstract != null && !string.IsNullOrWhiteSpace([email protected]))
                    {
                        abstractText = [email protected];
                    }
                }
            }

            if (inspireResource)
            {
                inspireResource = IsApplicableForInspireValidation(resourceType);
            }

            return(new MetadataEntry()
            {
                Uuid = uuid,
                Title = title,
                ResourceType = resourceType,
                ResponsibleOrganization = organization,
                InspireResource = inspireResource,
                ValidationResults = new List <ValidationResult>(),
                ContactInformation = contactInformation.ToString(),
                Keywords = string.Join(", ", keywords),
                Purpose = purpose,
                Abstract = abstractText
            });
        }