Example #1
0
 private void connectAllFloors(List <Point3D> pointsToConnect, List <LineStringDTO> lineStrings, List <Point3D> pathPoints, Dictionary <string, Point3D> pillarPoints)
 {
     for (int i = 0; i < pointsToConnect.Count; i++)
     {
         //JObject jobjectSource = pointsToConnect[i];
         Point3D source = pointsToConnect[i];
         //source = extractPoint(0, jobjectSource, null, Point3D.PointType.PATH_POINT);
         if (!pathPoints.Contains(source))
         {
             pathPoints.Add(source);
         }
         for (int j = i + 1; j < pointsToConnect.Count; j++)
         {
             LineStringDTO toAdd = new LineStringDTO();
             //JObject jobjectTarget = pointsToConnect[j];
             Point3D target = pointsToConnect[j];
             //target = extractPoint(0, jobjectTarget, null, Point3D.PointType.PATH_POINT);
             if (!pathPoints.Contains(target))
             {
                 pathPoints.Add(target);
             }
             toAdd.Source        = source;
             toAdd.Target        = target;
             toAdd.Wkt           = "LINESTRING(" + source.Longitude + " " + source.Latitude + "," + target.Longitude + " " + target.Latitude + ")";
             toAdd.LocationG     = DbGeometry.LineFromText(toAdd.Wkt, 4326);
             toAdd.BiDirectional = true;
             toAdd.Distance      = GeoUtils.GetHaversineDistance(source, target);
             toAdd.Level         = source.Level;
             toAdd.setConnectorType();
             lineStrings.Add(toAdd);
         }
         pillarPoints.Remove(source.Name);
     }
 }
Example #2
0
        private void extractLineString(JObject feature, List <LineStringDTO> lineStrings, List <Point3D> pathPoints, Dictionary <string, Point3D> labeledPoints)
        {
            LineStringDTO toAdd = new LineStringDTO();
            int           level = int.Parse(feature["properties"]["level"].ToString());

            //bool isAccessible = Boolean.Parse(feature["properties"]["accessible"].ToString());
            toAdd.Level = level;
            if (feature["properties"]["attrs"]["name"] != null)
            {
                toAdd.Name = feature["properties"]["attrs"]["name"].ToString();
            }
            StringBuilder wktsb = new StringBuilder("LINESTRING (");
            //List<Point3D> labeledPointsFound = new List<Point3D>();
            //Point3D source = new Point3D();
            //Point3D target = new Point3D();
            int i = 0;

            foreach (JArray j in feature["geometry"]["coordinates"])
            {
                StringBuilder pointWkt = new StringBuilder("POINT (");
                string        lon      = Regex.Match(j.ToString(), "34\\.\\d+").Value;
                string        lat      = Regex.Match(j.ToString(), "32\\.\\d+").Value;
                wktsb.Append(lon + " " + lat + ",");
                pointWkt.Append(lon + " " + lat + ")");
                Point3D current = null;
                if (labeledPoints.ContainsKey(pointWkt.ToString()))
                {
                    current      = labeledPoints[pointWkt.ToString()];
                    current.Type = Point3D.PointType.PATH_POINT;
                    if (!pathPoints.Contains(current))
                    {
                        pathPoints.Add(current);
                    }
                }
                if (current == null)
                {
                    current = pathPoints.Find(x => x.Wkt == pointWkt.ToString() && x.Level == level);
                }
                else
                {
                    current = current;
                }

                if (current == null)
                {
                    current = new Point3D();
                    //current = i == 0 ? source : target;
                    current.Latitude  = Decimal.Parse(lat);
                    current.Longitude = Decimal.Parse(lon);
                    current.Wkt       = pointWkt.ToString();
                    current.LocationG = DbGeometry.PointFromText(current.Wkt, 4326);
                    current.Level     = level;
                    current.Type      = Point3D.PointType.PATH_POINT;
                    pathPoints.Add(current);
                }
                else
                {
                    i = i;
                }
                if (i == 0)
                {
                    toAdd.Source = current;
                }
                if (i == 1)
                {
                    toAdd.Target = current;
                }
                i++;
            }
            wktsb.Remove(wktsb.Length - 1, 1);
            wktsb.Append(")");
            toAdd.Wkt           = wktsb.ToString();
            toAdd.LocationG     = DbGeometry.LineFromText(toAdd.Wkt, 4326);
            toAdd.Distance      = GeoUtils.GetHaversineDistance(toAdd.Source, toAdd.Target);
            toAdd.BiDirectional = true;
            //if (toAdd.Target.Longitude == 34.7745353108864M)
            //   Debugger.Break();
            toAdd.setConnectorType();
            lineStrings.Add(toAdd);
        }
Example #3
0
        private void getAdjacentLevelsConnectors(Dictionary <string, Point3D> pillarPoints, List <LineStringDTO> lineStrings, List <Point3D> pathPoints)
        {
            HashSet <string> pillarPOintsUsed = new HashSet <string>();
            List <string>    pillarsList      = pillarPoints.Keys.ToList();

            foreach (string name in pillarsList)
            {
                //if (name == "2-3BRamp")
                //    Debugger.Break();
                if (!pillarPoints.ContainsKey(name))
                {
                    continue;
                }
                //JObject j = pillarPoints[name];
                Point3D source = pillarPoints[name];
                //source = extractPoint(0, j, null, Point3D.PointType.PATH_POINT);
                if (source.Name.Length < 3)
                {
                    continue;
                }
                if (pathPoints.Contains(source))
                {
                    source      = pathPoints.Find(x => x == source);
                    source.Name = name;
                }
                else
                {
                    pathPoints.Add(source);
                }
                char   startlevel = source.Name[0];
                char   endlevel   = source.Name[2];
                string destname   = source.Name.Remove(0, 1).Insert(0, endlevel.ToString()).Remove(2, 1).Insert(2, startlevel.ToString());
                if (!pillarPoints.ContainsKey(destname))
                {
                    continue;
                }
                LineStringDTO toAdd = new LineStringDTO();
                //j = pillarPoints[destname];
                Point3D target = pillarPoints[destname];
                //target = extractPoint(0, j, null, Point3D.PointType.PATH_POINT);
                if (pathPoints.Contains(target))
                {
                    target      = pathPoints.Find(x => x == target);
                    target.Name = destname;
                    target.Type = Point3D.PointType.LEVEL_CONNECTION;
                }
                else
                {
                    pathPoints.Add(target);
                }
                toAdd.Source    = source;
                toAdd.Target    = target;
                toAdd.Wkt       = "LINESTRING(" + source.Longitude + " " + source.Latitude + "," + target.Longitude + " " + target.Latitude + ")";
                toAdd.LocationG = DbGeometry.LineFromText(toAdd.Wkt, 4326);
                toAdd.Distance  = GeoUtils.GetHaversineDistance(source, target);
                toAdd.Level     = source.Level;
                if (source.Name.Contains("Esc"))
                {
                    if (source.Name.Contains("EscBi"))
                    {
                        toAdd.BiDirectional = true;
                    }
                    else
                    {
                        toAdd.BiDirectional = false;
                    }
                }
                toAdd.setConnectorType();
                lineStrings.Add(toAdd);
                pillarPoints.Remove(name);
                pillarPoints.Remove(destname);
            }
        }