Example #1
0
 public NatureAreaExport(NatureArea natureArea)
 {
     Version      = natureArea.Version;
     Nivå         = natureArea.Nivå;
     Surveyed     = natureArea.Surveyed;
     Description  = natureArea.Description;
     UniqueId     = natureArea.UniqueId;
     Area         = natureArea.Area;
     AreaEpsgCode = natureArea.AreaEpsgCode;
     Surveyer     = natureArea.Surveyer;
     Documents    = natureArea.Documents;
     Parameters   = natureArea.Parameters;
 }
        public void StoreDataDeliveryTest()
        {
            var identification = new Identification
            {
                LocalId   = Guid.NewGuid(),
                NameSpace = "DataAccessTest",
                VersionId = "1.0"
            };

            var natureArea = new NatureArea
            {
                UniqueId = identification,
                Version  = "2.0",
                Nivå     = NatureLevel.Natursystem,
                //Area = SqlGeometry.STPolyFromText(new SqlChars("POLYGON ((5 5, 10 5, 10 10, 5 5))"), 0),
                //Area = SqlGeometry.STPolyFromText(new SqlChars("POLYGON ((-11 55, -10 35, -5.5 36, -1 36, 1 38, 5 38, 11 38, 14 36, 26 33, 29 36, 26 39, 29 46, 39 47, 40 49, 27 56, 27 60, 25 60, 20 58, 21 56, 19 55, 11 55, 10 57, 7 57, 8 54, 3 53, -2 60, -8 58, -11 55))"), 0),
                Area         = "POLYGON ((-11 55, -10 35, -5.5 36, -1 36, 1 38, 5 38, 11 38, 14 36, 26 33, 29 36, 26 39, 29 46, 39 47, 40 49, 27 56, 27 60, 25 60, 20 58, 21 56, 19 55, 11 55, 10 57, 7 57, 8 54, 3 53, -2 60, -8 58, -11 55))",
                AreaEpsgCode = 25832,
                Surveyer     = new Contact
                {
                    Company       = "Norconsult informasjonssystemer AS",
                    ContactPerson = "Magne Tøndel",
                    Email         = "*****@*****.**",
                    Phone         = "+4748164614",
                    Homesite      = "www.nois.no"
                },
                Surveyed    = new DateTime(2015, 9, 18, 19, 00, 00),
                Description = "Description"
            };

            natureArea.Documents.Add(new Document
            {
                Title       = "NatureAreaDocumentOne",
                Description = "Description",
                Author      = new Contact
                {
                    Company       = "Norconsult informasjonssystemer AS",
                    ContactPerson = "Magne Tøndel",
                    Email         = "*****@*****.**",
                    Phone         = "+4748164614",
                    Homesite      = "www.nois.no"
                },
                FileName = "C:\\Document\\TestNatureAreaOne"
            });
            natureArea.Documents.Add(new Document
            {
                Title       = "NatureAreaDocumentTwo",
                Description = "Description",
                Author      = new Contact
                {
                    Company       = "Norconsult informasjonssystemer AS",
                    ContactPerson = "Magne Tøndel",
                    Email         = "*****@*****.**",
                    Phone         = "+4748164614",
                    Homesite      = "www.nois.no"
                },
                FileName = "C:\\Document\\TestNatureAreaTwo"
            });

            var metadata = new Metadata
            {
                UniqueId           = identification,
                Program            = "Program",
                ProjectName        = "ProjectName",
                ProjectDescription = "ProjectDescription",

                Quality = new Quality
                {
                    MeasuringMethod       = "Terrengmålt: Uspesifisert måleinstrument",
                    Accuracy              = 1,
                    Visibility            = "Fullt ut synlig/gjenfinnbar i terrenget",
                    MeasuringMethodHeight = "Terrengmålt: Totalstasjon",
                    AccuracyHeight        = 2,
                    MaxDeviation          = 3,
                },
            };

            metadata.NatureAreas.Add(natureArea);

            metadata.Documents.Add(
                new Document
            {
                Title       = "NatureAreaDocument",
                Description = "Description",
                FileName    = "C:\\Document\\TestMetadata"
            }
                );

            var dataDelivery = new Dataleveranse
            {
                Name         = "DataDeliveryTest",
                DeliveryDate = DateTime.Now,
                Metadata     = metadata,
                Created      = new DateTime(2015, 9, 17, 12, 30, 30),
                Publisering  = Status.Importert
            };

            var id = dbInterface.LagreDataleveranse(dataDelivery);

            Assert.IsNotEmpty(id);
        }
        private static NatureArea ParseNatureArea2(XElement element)
        {
            var natureArea = new NatureArea();

            var natureAreaUniqueIds =
                NinXmlParser.GetChildElements(element, "unikId", TillatAntall.AkkuratEn);

            natureArea.UniqueId = ParseIdentification(natureAreaUniqueIds[0]);

            var natureAreaVersions =
                NinXmlParser.GetChildElements(element, "versjon", TillatAntall.AkkuratEn);

            natureArea.Version = natureAreaVersions[0].Value;

            var natureAreaNatureLevels =
                NinXmlParser.GetChildElements(element, "nivaa", TillatAntall.AkkuratEn);
            var xNaturnivå = natureAreaNatureLevels[0];

            switch (xNaturnivå.Value)
            {
            case "1":
                natureArea.Nivå = NatureLevel.Landskapstype;
                break;

            case "2":
                natureArea.Nivå = NatureLevel.Landskapsdel;
                break;

            case "3":
                natureArea.Nivå = NatureLevel.Naturkompleks;
                break;

            case "4":
                natureArea.Nivå = NatureLevel.Natursystem;
                break;

            case "5":
                natureArea.Nivå = NatureLevel.Naturkomponent;
                break;

            case "6":
                natureArea.Nivå = NatureLevel.Livsmedium;
                break;

            case "7":
                natureArea.Nivå = NatureLevel.KnowledgeArea;
                break;

            default:
                throw new DataDeliveryParseException("The element " + xNaturnivå.Name.LocalName +
                                                     " contains a unknown value.");
            }

            var natureAreaAreas =
                NinXmlParser.GetChildElements(element, "omraade", TillatAntall.AkkuratEn);
            int natureAreaEpsgCode;

            natureArea.Area         = NinXmlParser.ParseGeometry(natureAreaAreas[0], out natureAreaEpsgCode);
            natureArea.AreaEpsgCode = natureAreaEpsgCode;

            var natureAreaSurveyers = NinXmlParser.GetChildElements(element, "kartlegger",
                                                                    TillatAntall.MaksimaltEn);

            if (natureAreaSurveyers.Count == 1)
            {
                natureArea.Surveyer = NinXmlParser.ParseContact(natureAreaSurveyers[0]);
            }
            var natureAreaSurveyeds = NinXmlParser.GetChildElements(element, "kartlagtDato",
                                                                    TillatAntall.MaksimaltEn);

            if (natureAreaSurveyeds.Count == 1)
            {
                natureArea.Surveyed = Convert.ToDateTime(natureAreaSurveyeds[0].Value);
            }

            var natureAreaDescriptions = NinXmlParser.GetChildElements(element, "beskrivelse",
                                                                       TillatAntall.MaksimaltEn);

            if (natureAreaDescriptions.Count == 1)
            {
                natureArea.Description = natureAreaDescriptions[0].Value;
            }

            var natureAreaDocuments = NinXmlParser.GetChildElements(element, "dokumenter",
                                                                    TillatAntall.NullEllerFlere);

            foreach (var natureAreaDocument in natureAreaDocuments)
            {
                natureArea.Documents.Add(NinXmlParser.ParseDocument(natureAreaDocument));
            }

            var natureAreaParameters = NinXmlParser.GetChildElements(element, "parametre",
                                                                     TillatAntall.EnEllerFlere);

            foreach (var natureAreaParameter in natureAreaParameters)
            {
                natureArea.Parameters.Add(ParseParameter(natureAreaParameter));
            }

            return(natureArea);
        }