Beispiel #1
0
        public LineString3D <Point3D> toGeneric()
        {
            LineString3D <Point3D> toRet = new LineString3D <Point3D>
            {
                Id            = this.Id,
                Distance      = this.distance,
                Wkt           = this.Wkt,
                LocationG     = this.LocationG,
                Name          = this.Name,
                Target        = this.Target,
                Source        = this.Source,
                IsAccessible  = this.IsAccessible,
                BiDirectional = this.BiDirectional,
                Level         = this.Level,
                connectorType = this.connectorType
            };

            return(toRet);
        }
Beispiel #2
0
        private List <GraphDataItem> GetAdditionalEdgeOfSourceOrTargetToNearest(ApplicationDbContext db, List <IHasEntrances> storeContainers, Point3D point, IQueryable <Point3D> pathPoints, bool isTarget)
        {
            List <GraphDataItem> toReturn = new List <GraphDataItem>();

            if (storeContainers.Count == 1)
            {
                int maxid = (int)db.LineStrings.Max(x => x.Id);
                if (storeContainers[0].Entrances == null)
                {
                    db.Stores.Attach((Store)storeContainers[0]);
                    db.Entry(storeContainers[0]).Collection(x => x.Entrances).Load();
                }
                foreach (var item in storeContainers[0].Entrances)
                {
                    double distance = GeoUtils.GetHaversineDistance(point, item);
                    toReturn.Add(new GraphDataItem
                    {
                        Cost           = distance,
                        EdgeID         = maxid++,
                        IsReverse      = true,
                        ReverseCost    = distance,
                        SourceVertexID = isTarget ? (int)item.Id : (int)point.Id,
                        TargetVertexID = isTarget ? (int)point.Id : (int)item.Id,
                        Name           = item.Name,
                    });
                }
            }
            if (storeContainers.Count == 0)
            {
                double  minToSource   = double.MaxValue;
                Point3D closestSource = null;
                foreach (Point3D pointFromAll in pathPoints.Where(x => x.Level == point.Level))
                {
                    double toSource = GeoUtils.GetHaversineDistance(pointFromAll, point);
                    if (toSource < minToSource)
                    {
                        minToSource   = toSource;
                        closestSource = pointFromAll;
                    }
                }
                if (closestSource == null)
                {
                    return(null);
                }
                LineString3D <Point3D> pointToNearestPath = new LineString3D <Point3D>
                {
                    Level    = point.Level,
                    Source   = isTarget ? closestSource : point,
                    Target   = isTarget ? point : closestSource,
                    Distance = minToSource,
                    Name     = "Edge To Target"
                };

                if (isTarget)
                {
                    pointToNearestPath.Name = "Edge from source";
                }
                pointToNearestPath.setWktAndLocationG();
                toReturn.Add(new GraphDataItem {
                    Cost = pointToNearestPath.Distance, ReverseCost = pointToNearestPath.Distance, EdgeID = (int)pointToNearestPath.Id, IsReverse = true, SourceVertexID = (int)pointToNearestPath.Source.Id, TargetVertexID = (int)pointToNearestPath.Target.Id
                });
            }
            return(toReturn);
        }