예제 #1
0
        private void ReadGeometry(XElement xReader, OGCFeature feature)
        {
            feature._Envelope = new OGCEnvelope();

            //      <GEOMETRY>
            //        <gml:LineString srsName="EPSG:4326">
            //          <gml:posList>-132.901294 55.33849098 -132.8861369 55.24352568</gml:posList>
            //        </gml:LineString>
            //      </GEOMETRY>

            //while (xReader.Read())
            //{
            //    if (xReader.NodeType == XmlNodeType.Element)
            //    {
            //    }
            //    else if (xReader.NodeType == XmlNodeType.EndElement)
            //    {
            //        if (xReader.Name == "GEOMETRY") break;
            //    }
            //}
        }
예제 #2
0
        private void ReadEnvelope(XElement xReader, OGCFeature feature)
        {
            feature._Envelope = new OGCEnvelope();

            //    <gml:Envelope srsName="urn:ogc:def:crs:EPSG::4326">
            //      <gml:lowerCorner>48.05543511 -141.747323</gml:lowerCorner>
            //      <gml:upperCorner>67.67964198 -88.73328852</gml:upperCorner>
            //    </gml:Envelope>

            string[] coords;

            foreach (XElement element in xReader.Descendants())
            {
                if (element.NodeType == XmlNodeType.Element)
                {
                    if (element.Name.LocalName == "lowerCorner")
                    {
                        coords = element.Value.Split(' ');
                        feature._Envelope.minX = double.Parse(coords[0]);
                        feature._Envelope.minY = double.Parse(coords[1]);
                    }
                    else if (element.Name.LocalName == "upperCorner")
                    {
                        coords = element.Value.Split(' ');
                        feature._Envelope.maxX = double.Parse(coords[0]);
                        feature._Envelope.maxY = double.Parse(coords[1]);
                    }
                }
            }
        }
예제 #3
0
        private GISResponse ProcessQueryReturn(XmlReader returnDocument, string layerName)
        {
            //<wfs:FeatureCollection xmlns="http://www.cubewerx.com/cw" xmlns:cw="http://www.cubewerx.com/cw" xmlns:wfs="http://www.opengis.net/wfs" xmlns:gml="http://www.opengis.net/gml" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.cubewerx.com/cw http://demo.cubewerx.com/demo/cubeserv/cubeserv.cgi?DATASTORE=GSC&amp;service=WFS&amp;version=1.1.0&amp;request=DescribeFeatureType&amp;outputFormat=GML3&amp;typeName=FAULTS_CA  http://www.opengis.net/wfs http://schemas.cubewerx.com/schemas/wfs/1.1.0/wfs.xsd http://www.opengis.net/gml http://schemas.cubewerx.com/schemas/gml/3.1.1/base/feature.xsd">
            //  <gml:boundedBy>
            //    <gml:Envelope srsName="urn:ogc:def:crs:EPSG::4326">
            //      <gml:lowerCorner>48.05543511 -141.747323</gml:lowerCorner>
            //      <gml:upperCorner>67.67964198 -88.73328852</gml:upperCorner>
            //    </gml:Envelope>
            //  </gml:boundedBy>
            //  <gml:featureMember>
            //    <FAULTS_CA gml:id="CWFID.FAULTS_CA.0.744">
            //      <GEOMETRY>
            //        <gml:LineString srsName="EPSG:4326">
            //          <gml:posList>-132.901294 55.33849098 -132.8861369 55.24352568</gml:posList>
            //        </gml:LineString>
            //      </GEOMETRY>
            //      <FNODEX>30093</FNODEX>
            //      <TNODEX>38844</TNODEX>
            //      <LPOLYX>0</LPOLYX>
            //      <RPOLYX>0</RPOLYX>
            //      <LENGTH>10407.923</LENGTH>
            //      <FLTAPPX>0</FLTAPPX>
            //      <FLTAPP_ID>0</FLTAPP_ID>
            //      <SYMBOL>30</SYMBOL>
            //      <COMP>J. O. Wheeler</COMP>
            //      <DXF_LAYER>unclass_flt</DXF_LAYER>
            //      <COUNTRY>USA*</COUNTRY>
            //      <ENGDESC>unclassified fault</ENGDESC>
            //      <PAYS>Etats-Unis</PAYS>
            //      <FREDESC>faille de nature non difinie</FREDESC>
            //    </FAULTS_CA>
            //  </gml:featureMember>

            OGCFeatureResponse response = new OGCFeatureResponse();

            bool inElement = false;
            OGCFeature feature = new OGCFeature();

            try
            {
                var xDocument = XDocument.Load(returnDocument);

                var q = from c in xDocument.Descendants()
                        select c.Element("featuremember");


                foreach (XNode node1 in xDocument.DescendantNodes())
                {
                    if (node1.NodeType == XmlNodeType.Element)
                    {
                        XElement item = node1 as XElement;

                        foreach (XNode node in item.DescendantNodes())
                        {
                            //if (xReader.MoveToNextAttribute())
                            //{
                            //    feature._Fields.Add(new GISField("ID", xReader.Value));
                            //}

                            if (node.NodeType == XmlNodeType.Element)
                            {
                                XElement element = node as XElement;

                                if (element.Name.LocalName == layerName)
                                {
                                    if (element.HasAttributes)
                                    {
                                        feature._Fields.Add(new GISField("id", element.Attribute(XName.Get("id", "gml")).Value));
                                    }

                                    if (inElement)
                                    {
                                        response._features.Add(feature);
                                        feature = new OGCFeature();
                                    }
                                    else inElement = true;
                                }
                                else if (element.Name == "Envelope")
                                {
                                    ReadEnvelope(element, feature);
                                }
                                else if (element.Name == "GEOMETRY")
                                {
                                    //ReadGeometry(element, feature);
                                }
                                else feature._Fields.Add(new GISField(element.Name.LocalName, element.Value));
                            }
                            else if (node.NodeType == XmlNodeType.EndElement)
                            {
                                XElement endelement = node as XElement;
                                if (endelement.Name.LocalName == layerName)
                                {
                                    response._features.Add(feature);
                                    feature = new OGCFeature();
                                }
                            }
                        }
                    }
                }
            }
            catch (System.Exception ex)
            {
                string x = "read error";
            }

            return response;
        }