예제 #1
0
        public XDocument ToXml(Dataleveranse dataleveranse)
        {
            var xDocument = new XDocument(new XDeclaration("1.0", "utf-8", "no"));

            var dataDeliveryElement = new NinXElement("DataLeveranse", "",
                                                      new XAttribute(XNamespace.Xmlns + "gml", gmlNs),
                                                      new XAttribute(XNamespace.Xmlns + "nin", Config.Settings.Namespace.Nin),
                                                      new NinXElement("navn", "dataDelivery.Name", dataleveranse.Name),
                                                      new NinXElement("leveranseDato", "dataDelivery.DeliveryDate", dataleveranse.DeliveryDate),
                                                      XmlSkriver.ContactElement("operatoer", dataleveranse.Operator),
                                                      new NinXElement("grunnForEndring", "dataDelivery.ReasonForChange", dataleveranse.ReasonForChange),
                                                      new NinXElement("beskrivelse", "dataDelivery.Description", dataleveranse.Description),
                                                      AddMetadataElements(new Collection <Metadata> {
                dataleveranse.Metadata
            })
                                                      );

            dataDeliveryElement.Print("");
            xDocument.Add(dataDeliveryElement);

            var emptyElements = from element in xDocument.Descendants() where element.IsEmpty select element;

            while (emptyElements.Any())
            {
                emptyElements.Remove();
            }

            return(xDocument);
        }
예제 #2
0
        public static XElement AreaElement(XName elementName, SqlGeometry area, Guid localId)
        {
            var e = new NinXElement(elementName);

            if (area == null)
            {
                return(e);
            }

            var gmlXml = area.AsGml().Value;

            gmlXml = gmlXml.Replace(" xmlns=\"http://www.opengis.net/gml\"", "");

            var gmlElement = XElement.Parse(gmlXml);

            gmlElement.Add(new XAttribute((XNamespace)Config.Settings.Namespace.Gml + "id", "GEOMETRY_" + localId));
            gmlElement.Add(new XAttribute("srsName", "EPSG:" + area.STSrid));

            foreach (var gmlElementPart in gmlElement.DescendantsAndSelf())
            {
                gmlElementPart.Name = (XNamespace)Config.Settings.Namespace.Gml + gmlElementPart.Name.LocalName;
            }

            e.Add(gmlElement);

            return(e);
        }
예제 #3
0
        public XDocument ToXml(GridLayer gridLayer)
        {
            var xDocument = new XDocument(new XDeclaration("1.0", "utf-8", "no"));

            XElement gridNetElement = new NinXElement("RuteNettKart", "",
                                                      new XAttribute(XNamespace.Xmlns + "nin", Config.Settings.Namespace.Nin),
                                                      new XAttribute(XNamespace.Xmlns + "gml", gmlNs),
                                                      new NinXElement("navn", "gridLayer.Name", gridLayer.Name),
                                                      new NinXElement("beskrivelse", "gridLayer.Description", gridLayer.Description),
                                                      new NinXElement("kode", "AddCodeElement('Kode', gridLayer.Code)",
                                                                      AddCodeElement("Kode", gridLayer.Code)),
                                                      XmlSkriver.ContactElement("eier", gridLayer.Owner),
                                                      new NinXElement("etablertDato", "gridLayer.Established", gridLayer.Established),
                                                      new NinXElement("ruteNett", "(int)gridLayer.Type", (int)gridLayer.Type),
                                                      AddMapElements(gridLayer.Cells, gridLayer.Code != null ? gridLayer.Code.Value : string.Empty)
                                                      );

            xDocument.Add(gridNetElement);

            var emptyElements = from element in xDocument.Descendants() where element.IsEmpty select element;

            while (emptyElements.Any())
            {
                emptyElements.Remove();
            }

            return(xDocument);
        }
예제 #4
0
        private static XElement AddVariableDefinitionElement(XName elementName, Code code)
        {
            var vd = new NinXElement(elementName);

            if (code == null)
            {
                return(vd);
            }

            vd.Add(AddCodeElement("Kode", code));
            return(vd);
        }
예제 #5
0
        private static XElement AddStandardVariableElement(XName elementName, NinStandardVariabel standardVariable)
        {
            var sv = new NinXElement(elementName);

            if (standardVariable != null)
            {
                sv.Add(AddVariableDefinitionElement("variabelDefinisjon",
                                                    standardVariable.VariableDefinition));
            }

            return(sv);
        }
예제 #6
0
        private static XElement CustomVariableElement(CustomVariable customVariable, XName elementName)
        {
            var e = new NinXElement(elementName);

            if (customVariable == null)
            {
                return(e);
            }

            e.Add(new NinXElement("betegnelse", "customVariable.Specification", customVariable.Specification));
            e.Add(new NinXElement("verdi", "customVariable.Value", customVariable.Value));

            return(e);
        }
예제 #7
0
        private static XElement AddCodeElement(XName elementName, Types.Code code)
        {
            var codeElement = new NinXElement(elementName);

            if (code == null)
            {
                return(codeElement);
            }

            codeElement.Add(new NinXElement("koderegister", "code.Registry)", code.Registry));
            codeElement.Add(new NinXElement("kodeversjon", "code.Version)", code.Version));
            codeElement.Add(new NinXElement("kode", "code.Value)", code.Value));

            return(codeElement);
        }
예제 #8
0
        private static XElement AddCustomVariableDefinitionElement(XName elementName,
                                                                   CustomVariableDefinition customVariableDefinition)
        {
            var e = new NinXElement(elementName);

            if (customVariableDefinition == null)
            {
                return(e);
            }

            e.Add(new NinXElement("betegnelse", "customVariableDefinition.Specification)",
                                  customVariableDefinition.Specification));
            e.Add(new NinXElement("beskrivelse", "customVariableDefinition.Description)",
                                  customVariableDefinition.Description));

            return(e);
        }
예제 #9
0
        private static XElement DescriptionVariableElement(XName elementName, DescriptionVariable descriptionVariable)
        {
            var e = new NinXElement(elementName);

            if (descriptionVariable == null)
            {
                return(e);
            }

            e.Add(new NinXElement("kode", "descriptionVariable.Code", descriptionVariable.Code));
            e.Add(ContactElement("kartlegger", descriptionVariable.Surveyer));
            e.Add(new NinXElement("kartlagtDato", "descriptionVariable.Surveyed", descriptionVariable.Surveyed));
            e.Add(new NinXElement("verdi", "descriptionVariable.Value", descriptionVariable.Value));
            e.Add(new NinXElement("beskrivelse", "descriptionVariable.Description", descriptionVariable.Description));

            return(e);
        }
예제 #10
0
        public static XElement IdentificationElement(XName elementName, Identification identification)
        {
            var e = new NinXElement(elementName);

            if (identification == null)
            {
                return(e);
            }

            var ie = new NinXElement("Identifikasjon");

            ie.Add(new NinXElement("lokalId", "identification.LocalId", identification.LocalId));
            ie.Add(new NinXElement("navnerom", "identification.NameSpace", identification.NameSpace));
            ie.Add(new NinXElement("versjonId", "identification.VersionId", identification.VersionId));
            e.Add(ie);

            return(e);
        }
예제 #11
0
        private XElement NatureAreaTypeElement(XName elementName, NatureAreaType natureAreaType)
        {
            var e = new NinXElement(elementName);

            if (natureAreaType == null)
            {
                return(e);
            }

            e.Add(new NinXElement("kode", "natureAreaType.Code", natureAreaType.Code));
            e.Add(ContactElement("kartlegger", natureAreaType.Surveyer));
            e.Add(new NinXElement("kartlagtDato", "natureAreaType.Surveyed", natureAreaType.Surveyed));
            e.Add(new NinXElement("andel", "natureAreaType.Share", natureAreaType.Share));
            e.Add(CustomVariableElements(natureAreaType.CustomVariables));
            e.Add(AdditionalVariableElements(natureAreaType.AdditionalVariables));

            return(e);
        }
예제 #12
0
        public static XElement ContactElement(XName elementName, Contact contact)
        {
            var e = new NinXElement(elementName);

            if (contact == null)
            {
                return(e);
            }

            var ci = new NinXElement("Kontaktinformasjon");

            ci.Add(new NinXElement("firmaNavn", "contact.Company", contact.Company));
            ci.Add(new NinXElement("kontaktPerson", "contact.ContactPerson", contact.ContactPerson));
            ci.Add(new NinXElement("email", "contact.Email", contact.Email));
            ci.Add(new NinXElement("telefon", "contact.Phone", contact.Phone));
            ci.Add(new NinXElement("hjemmeside", "contact.Homesite", contact.Homesite));
            e.Add(ci);

            return(e);
        }
예제 #13
0
        public XDocument ToXml(IEnumerable <Metadata> metadatas)
        {
            var xDocument = new XDocument(new XDeclaration("1.0", "utf-8", "no"));

            XElement dataExportElement = new NinXElement("DataEksport", "",
                                                         new XAttribute(XNamespace.Xmlns + "gml", gmlNs),
                                                         new XAttribute(XNamespace.Xmlns + "nin", Config.Settings.Namespace.Nin),
                                                         new NinXElement("eksportDato", "DateTime.Now", DateTime.Now),
                                                         AddMetadataElements(metadatas)
                                                         );

            xDocument.Add(dataExportElement);

            var emptyElements = from element in xDocument.Descendants() where element.IsEmpty select element;

            while (emptyElements.Any())
            {
                emptyElements.Remove();
            }

            return(xDocument);
        }
예제 #14
0
        private static XElement AddQualityElement(XName elementName, Quality quality)
        {
            var e = new NinXElement(elementName);

            if (quality == null)
            {
                return(e);
            }
            var q = new NinXElement("Posisjonskvalitet");

            q.Add(new NinXElement("maalemetode", "quality.MeasuringMethod)",
                                  quality.MeasuringMethod));
            q.Add(new NinXElement("noeyaktighet", "quality.Accuracy)", quality.Accuracy));
            q.Add(new NinXElement("synbarhet", "quality.Visibility)", quality.Visibility));
            q.Add(new NinXElement("maalemetodeHoeyde", "quality.MeasuringMethodHeight)",
                                  quality.MeasuringMethodHeight));
            q.Add(new NinXElement("noeyaktighetHoeyde", "quality.AccuracyHeight)",
                                  quality.AccuracyHeight));
            q.Add(new NinXElement("maksimaltAvvik", "quality.MaxDeviation)",
                                  quality.MaxDeviation));
            e.Add(q);

            return(e);
        }