コード例 #1
0
        void repPoints_NeedDataSource(object source, GridNeedDataSourceEventArgs e)
        {
            if (this.ucPoint.SelectedPoint != null || this.ucPoint.PointID > 0)
            {
                BusinessLogicLayer.IPoint busPoint = new BusinessLogicLayer.Point();
                Entities.Point            point    = (this.ucPoint.SelectedPoint != null) ? this.ucPoint.SelectedPoint : null;

                if (point == null)
                {
                    point = busPoint.GetPointForPointId(this.ucPoint.PointID);
                }

                if (point == null)
                {
                    this.ucPoint.SelectedPoint = null;
                    this.ucPoint.PointID       = -1;
                    this.repPoints.DataSource  = new DataTable();
                }
                else
                {
                    this.repPoints.DataSource = new DataTable();
                    repPoints.DataSource      = busPoint.GetFuzzyPointsToMerge(this.ucPoint.SelectedPoint.Description, float.Parse(this.pointDescriptionRadSlider.SelectedValue), String.Empty, 0, this.ucPoint.SelectedPoint.Address.AddressLine1,
                                                                               float.Parse(this.addressLine1RadSlider.SelectedValue), this.ucPoint.SelectedPoint.Address.PostTown, float.Parse(this.townRadSlider.SelectedValue),
                                                                               this.chkMatchOnPostCode.Checked ? this.ucPoint.SelectedPoint.Address.PostCode : String.Empty, 0);
                }
            }
            else
            {
                this.repPoints.DataSource = new DataTable();
            }
        }
コード例 #2
0
ファイル: point.ascx.cs プロジェクト: norio-soft/proteo
        public PointCollection GetPossibleDuplicates()
        {
            BusinessLogicLayer.IPoint busPoint        = new BusinessLogicLayer.Point();
            PointCollection           pointCollection = busPoint.GetPossibleDuplicates(this.txtDescription.Text, this.cboNewPointOwner.Text, this.txtAddressLine1.Text, this.txtPostTown.Text, this.txtPostCode.Text);

            if (pointCollection.Count > 0)
            {
                this.lvDuplicateAddress.DataSource = pointCollection;
                this.lvDuplicateAddress.DataBind();
                this.divDuplicateAddress.Visible = true;
            }

            return(pointCollection);
        }
コード例 #3
0
 private void LoadData()
 {
     if (this.ucPoint.SelectedPoint != null)
     {
         BusinessLogicLayer.IPoint busPoint = new BusinessLogicLayer.Point();
         repPoints.DataSource = busPoint.GetFuzzyPointsToMerge(this.ucPoint.SelectedPoint.Description, float.Parse(this.pointDescriptionRadSlider.SelectedValue), String.Empty, 0, this.ucPoint.SelectedPoint.Address.AddressLine1,
                                                               float.Parse(this.addressLine1RadSlider.SelectedValue), this.ucPoint.SelectedPoint.Address.PostTown, float.Parse(this.townRadSlider.SelectedValue),
                                                               this.chkMatchOnPostCode.Checked ? this.ucPoint.SelectedPoint.Address.PostCode : String.Empty, 0);
     }
     else
     {
         this.repPoints.DataSource = null;
     }
 }
コード例 #4
0
        public List <VehicleNearLocationItem> GetVehicleIntersectionsForDateTimeAndRadius(DateTime startDateTime, DateTime endDateTime, int radius, double latitude, double longitude, int?clientIdentityID = null)
        {
            BusinessLogicLayer.IPoint      busPoint     = new BusinessLogicLayer.Point();
            List <VehicleNearLocationItem> vehicleItems = new List <VehicleNearLocationItem>();
            DataSet ds            = null;
            double  metresPerMile = 1609.344;

            try
            {
                SqlGeography position = this.BuildGeography(new List <LatLong>()
                {
                    new LatLong()
                    {
                        Latitude = latitude, Longitude = longitude
                    }
                }, OpenGisGeographyType.Point);

                SqlGeography sqlInnerPoint = position.STBuffer(0.1);
                SqlGeography sqlGeofence   = position.STBuffer(radius * metresPerMile);

                ds = busPoint.GetVehicleIntersectionsForDateTimeAndGeofence(startDateTime, endDateTime, sqlGeofence, sqlInnerPoint, clientIdentityID);

                if (ds != null && ds.Tables.Count > 0)
                {
                    foreach (DataRow dr in ds.Tables[0].Rows)
                    {
                        VehicleNearLocationItem vnl = new VehicleNearLocationItem();
                        vnl.GPSPositionHistoryId = dr.Field <int>("GPSPositionHistoryId");
                        vnl.GPSUnitId            = dr.Field <string>("GPSUnitId");
                        vnl.ResourceRef          = dr.Field <string>("ResourceRef");
                        vnl.DistanceFromPoint    = dr.Field <double>("DistanceFromPoint");
                        vnl.LastResponseTime     = dr.Field <DateTime>("LastResponseTime");
                        vnl.Latitude             = dr.Field <double>("Latitude");
                        vnl.Longitude            = dr.Field <double>("Longitude");
                        vehicleItems.Add(vnl);
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }

            return(vehicleItems);
        }
コード例 #5
0
        public List <Orchestrator.WebUI.Services.Point> GetPointsPenetrated(List <LatLong> latLongs)
        {
            List <Orchestrator.WebUI.Services.Point> points = new List <Orchestrator.WebUI.Services.Point>();

            if (latLongs.Count > 0)
            {
                SqlGeographyBuilder geogBuilder = new SqlGeographyBuilder();
                geogBuilder.SetSrid(4326);
                geogBuilder.BeginGeography(OpenGisGeographyType.LineString);

                LatLong firstLatLong       = null;
                bool    firstLatLongStored = false;
                foreach (LatLong latLong in latLongs)
                {
                    if (!firstLatLongStored)
                    {
                        firstLatLong = latLong;
                        geogBuilder.BeginFigure(firstLatLong.Latitude, firstLatLong.Longitude);
                        firstLatLongStored = true;
                    }
                    else
                    {
                        geogBuilder.AddLine(latLong.Latitude, latLong.Longitude);
                    }
                }

                //geogBuilder.AddLine(firstLatLong.Latitude, firstLatLong.Longitude); //Note: Last Point same as First
                geogBuilder.EndFigure();

                geogBuilder.EndGeography();
                SqlGeography rectangle = null;

                try
                {
                    rectangle = geogBuilder.ConstructedGeography;
                }
                catch (Exception ex)
                {
                    //SqlGeometryBuilder gb = new SqlGeometryBuilder();
                    //gb.SetSrid(4326);
                    //gb.BeginGeometry(OpenGisGeometryType.Polygon);

                    //firstLatLong = null;
                    //firstLatLongStored = false;
                    //foreach (LatLong latLong in latLongs)
                    //{
                    //    if (!firstLatLongStored)
                    //    {
                    //        firstLatLong = latLong;
                    //        gb.BeginFigure(firstLatLong.Latitude, firstLatLong.Longitude);
                    //        firstLatLongStored = true;
                    //    }
                    //    else
                    //        gb.AddLine(latLong.Latitude, latLong.Longitude);
                    //}

                    //gb.AddLine(firstLatLong.Latitude, firstLatLong.Longitude); //Note: Last Point same as First
                    //gb.EndFigure();

                    //gb.EndGeometry();

                    //SqlGeometry geom = null;
                    //geom = gb.ConstructedGeometry.MakeValid();

                    ////geom = geom.MakeValid().STUnion(geom.STStartPoint());

                    //rectangle = SqlGeography.STPolyFromText(geom.STAsText(), 4326);
                }

                SqlDataReader dr = null;
                try
                {
                    BusinessLogicLayer.IPoint busPoint = new BusinessLogicLayer.Point();

                    dr = busPoint.GetPointsIntersected(rectangle);

                    while (dr.Read())
                    {
                        Orchestrator.WebUI.Services.Point point = new Orchestrator.WebUI.Services.Point();
                        point.GeofencePoints = new List <LatLong>();
                        point.Description    = dr["PointName"].ToString();
                        point.Latitide       = dr["WGS84Latitude"] != DBNull.Value ? Convert.ToDouble(dr["WGS84Latitude"]) : 0;
                        point.Longitude      = dr["WGS84Longitude"] != DBNull.Value ? Convert.ToDouble(dr["WGS84Longitude"]) : 0;
                        point.PointID        = int.Parse(dr["PointId"].ToString());
                        SqlGeography geofence = (SqlGeography)dr["Geofence"];

                        for (int i = 0; i < geofence.STNumPoints(); i++)
                        {
                            SqlGeography p       = geofence.STPointN(i + 1);
                            LatLong      latLong = new LatLong();
                            latLong.Latitude  = (double)p.Lat;
                            latLong.Longitude = (double)p.Long;
                            point.GeofencePoints.Add(latLong);
                        }
                        points.Add(point);
                    }
                }
                catch (Exception ex)
                {
                    throw;
                }
                finally
                {
                    dr.Close();
                }
            }

            return(points);
        }