public ActionResult AJAXGetRavePins()
        {
            FacetCollection<Rave> facets = new FacetCollection<Rave>();
            facets.Add(new FutureRavesFacet());
            facets.Add(new DisplayableRavesFacet());

            return Json(GetRavePins(facets), JsonRequestBehavior.AllowGet);
        }
        private IList<RavePin> GetRavePins(FacetCollection<Rave> facets)
        {
            IList<RavePin> results = new List<RavePin>();
            using (RaveRadarContext _db = new RaveRadarContext())
            {
                IQueryable<Rave> filteredRaves = _db.Raves.AsQueryable();
                if (facets != null)
                {
                    filteredRaves = facets.Filter(filteredRaves);
                }

                results = (from r in filteredRaves
                          join v in _db.Venues on r.VenueID equals v.VenueID
                          orderby r.StartTime
                          select new RavePin
                              {
                                  ID = r.ID,
                                  PicURL = r.PicURL ?? string.Empty,
                                  Location = r.Location,
                                  Latitude = v.Latitude,
                                  Longitude = v.Longitude,
                              }).ToList();
            }

            return results;
        }
    private List<int> SelectPolys(double inputAngle, FacetCollection facetCollection, List<int> allSelectedPolygons, List<int> neighSelectedPolygons, Array normalArray)
    {
        List<int> tempArray = new List<int>();

        //for each selected polys get neighbor polygons
        for (int i = 0; i < neighSelectedPolygons.Count; i++)
        {

            PolygonFace pFace = (PolygonFace)facetCollection[neighSelectedPolygons[i]];
            PolygonFaceCollection neighborPolys = (PolygonFaceCollection)pFace.NeighborPolygons();
            if (neighborPolys.Count == 0) continue;

            SIVector3 firstNormal, secondNormal;

            firstNormal = GetMath().CreateVector3((double)normalArray.GetValue(0, pFace.Index),
                                                (double)normalArray.GetValue(1, pFace.Index),
                                                (double)normalArray.GetValue(2, pFace.Index));

            foreach (PolygonFace neiPoly in neighborPolys)
            {
                if (allSelectedPolygons.Contains(neiPoly.Index)) continue;

                secondNormal = GetMath().CreateVector3((double)normalArray.GetValue(0, neiPoly.Index),
                                                            (double)normalArray.GetValue(1, neiPoly.Index),
                                                            (double)normalArray.GetValue(2, neiPoly.Index));

                double angle = Math.Abs(firstNormal.Angle(secondNormal));
                if (angle < inputAngle)
                {
                    if (!tempArray.Contains(neiPoly.Index)) tempArray.Add(neiPoly.Index);
                }
            }
        }

        if (tempArray.Count > 0)
        {
            allSelectedPolygons.AddRange(tempArray);
            tempArray.AddRange(SelectPolys(inputAngle, facetCollection, allSelectedPolygons, tempArray, normalArray));
        }

        return tempArray;
    }