コード例 #1
0
 public void AcceptChangesAppearAsUnchanged()
 {
     FeatureDataTable table = new FeatureDataTable();
     FeatureDataRow row = table.NewRow();
     table.AddRow(row);
     table.AcceptChanges();
     Assert.AreEqual(DataRowState.Unchanged, row.RowState);
 }
コード例 #2
0
 public void AcceptChangesReturnsNullChangesTable()
 {
     FeatureDataTable table = new FeatureDataTable();
     FeatureDataRow row = table.NewRow();
     table.AddRow(row);
     table.AcceptChanges();
     FeatureDataTable changes = table.GetChanges();
     Assert.IsNull(changes);
 }
コード例 #3
0
        public void AcceptChangesAppearAsUnchanged()
        {
            FeatureDataTable table = new FeatureDataTable(_factories.GeoFactory);
            FeatureDataRow   row   = table.NewRow();

            table.AddRow(row);
            table.AcceptChanges();
            Assert.Equal(DataRowState.Unchanged, row.RowState);
        }
コード例 #4
0
        public void AcceptChangesReturnsNullChangesTable()
        {
            FeatureDataTable table = new FeatureDataTable(_factories.GeoFactory);
            FeatureDataRow   row   = table.NewRow();

            table.AddRow(row);
            table.AcceptChanges();
            FeatureDataTable changes = table.GetChanges();

            Assert.Null(changes);
        }
コード例 #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="GeometryProvider"/>
        /// </summary>
        /// <param name="geometry">Geometry to be in this datasource</param>
        public GeometryFeatureProvider(Geometry geometry)
        {
            _features = new FeatureDataTable();
            var fdr = _features.NewRow();

            fdr.Geometry = geometry;
            if (geometry != null)
            {
                SRID = geometry.SRID;
            }
            _features.AddRow(fdr);
            _features.AcceptChanges();

            _features.TableCleared += HandleFeaturesCleared;
            _features.Constraints.CollectionChanged += HandleConstraintsCollectionChanged;
        }
コード例 #6
0
        private int _oid  = -1; // primary key index from fdt schema or subsequently added unique constraint

        #region constructors

        /// <summary>
        /// Initializes a new instance of the <see cref="GeometryProvider"/>
        /// </summary>
        /// <param name="geometries">Set of geometries that this datasource should contain</param>
        public GeometryFeatureProvider(IEnumerable <Geometry> geometries)
        {
            _features = new FeatureDataTable();
            _features.BeginLoadData();
            foreach (var geom in geometries)
            {
                var fdr = _features.NewRow();
                fdr.Geometry = geom;
                _features.AddRow(fdr);
            }
            _features.AcceptChanges();
            _features.EndLoadData();

            _features.TableCleared += HandleFeaturesCleared;
            _features.Constraints.CollectionChanged += HandleConstraintsCollectionChanged;

            if (_features.Count > 0 && _features[0].Geometry != null)
            {
                SRID = _features[0].Geometry.SRID;
            }
        }
コード例 #7
0
            /// <summary>
            /// gets realtime data from public transport in city vilnius of lithuania
            /// </summary>
            private void GetVilniusTransportData(string line)
            {
                if (_isActive)
                {
                    return;
                }
                _isActive = true;

                //List<FeatureDataRow> newFeatures = new List<FeatureDataRow>();
                FeatureDataTable fdt = VehicleDataTable();

                string url = "http://www.troleibusai.lt/puslapiai/services/vehiclestate.php?type=";

                switch (_transportType)
                {
                case TransportType.Bus:
                {
                    url += "bus";
                }
                break;

                case TransportType.TrolleyBus:
                {
                    url += "trolley";
                }
                break;
                }

                if (!string.IsNullOrEmpty(line))
                {
                    url += "&line=" + line;
                }

                url += "&app=SharpMap.WinFormSamples";

                HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

                request.Timeout          = Timeout;
                request.ReadWriteTimeout = request.Timeout;
                request.Accept           = "*/*";
                request.KeepAlive        = false;

                string xml;

                using (HttpWebResponse response = request.GetResponse() as HttpWebResponse)
                {
                    if (response == null)
                    {
                        return;
                    }

                    using (Stream responseStream = response.GetResponseStream())
                    {
                        if (responseStream == null)
                        {
                            return;
                        }
                        using (StreamReader read = new StreamReader(responseStream))
                        {
                            xml = read.ReadToEnd();
                        }
                    }
                }

                XmlDocument doc = new XmlDocument();

                {
                    doc.LoadXml(xml);

                    XmlNodeList devices = doc.GetElementsByTagName("Device");
                    foreach (XmlNode dev in devices)
                    {
                        if (dev.Attributes == null)
                        {
                            continue;
                        }

                        double?        lat = null, lng = null;
                        FeatureDataRow dr = fdt.NewRow();
                        dr["Id"] = int.Parse(dev.Attributes["ID"].InnerText);
                        foreach (XmlElement elem in dev.ChildNodes)
                        {
                            // Debug.WriteLine(d.Id + "->" + elem.Name + ": " + elem.InnerText);

                            switch (elem.Name)
                            {
                            case "Lat":
                                lat = double.Parse(elem.InnerText, CultureInfo.InvariantCulture);
                                break;

                            case "Lng":
                                lng = double.Parse(elem.InnerText, CultureInfo.InvariantCulture);
                                break;

                            case "Bearing":
                                if (!string.IsNullOrEmpty(elem.InnerText))
                                {
                                    dr["Bearing"] = double.Parse(elem.InnerText, CultureInfo.InvariantCulture);
                                }
                                break;

                            case "LineNum":
                                dr["Line"] = elem.InnerText;
                                break;

                            case "AreaName":
                                dr["AreaName"] = elem.InnerText;
                                break;

                            case "StreetName":
                                dr["StreetName"] = elem.InnerText;
                                break;

                            case "TrackType":
                                dr["TrackType"] = elem.InnerText;
                                break;

                            case "LastStop":
                                dr["LastStop"] = elem.InnerText;
                                break;

                            case "Time":
                                dr["Time"] = elem.InnerText;
                                break;
                            }
                        }

                        if (lat.HasValue && lng.HasValue)
                        {
                            dr.Geometry = _factory.CreatePoint(new Coordinate(lng.Value, lat.Value));
                            fdt.Rows.Add(dr);
                        }
                    }
                }

                Features.Clear();
                FeatureDataTable features = (FeatureDataTable)Features;

                foreach (FeatureDataRow featureDataRow in fdt.Rows)
                {
                    FeatureDataRow fdr = features.NewRow();
                    fdr.ItemArray = featureDataRow.ItemArray;
                    fdr.Geometry  = featureDataRow.Geometry;
                    features.AddRow(fdr);
                }
                features.AcceptChanges();

                _isActive = false;
            }