コード例 #1
0
 private void AddAreasToCollection(MapItemCollection collection, IEnumerable <Area> areas, CfType placeType, string placeTypeString)
 {
     foreach (var a in areas)
     {
         collection.AddPoint(a.Name, a.SearchSupportString, a.SlugUrl, a.Avatar, placeTypeString, a.Latitude, a.Longitude);
     }
 }
コード例 #2
0
        private void AddRelatedAreasToCollection(MapItemCollection collection, Area area, bool provinces, bool cities, bool outdoorAreas)
        {
            var relatedAreas = areaRepo.GetIntersectingAreasWithGeoInflate(area.ID);

            //if (provinces)
            //{
            //    var intersectingCities = relatedAreas.Where(c => c.GeoType == Entities.Enum.GeographyType.Province);
            //    foreach (var city in intersectingCities)
            //    {
            //        SqlGeography center = city.Geo.EnvelopeCenter();
            //        collection.AddPoint(city.Name, city.SearchSupportString, center.Lat.Value, center.Long.Value, "Cty");
            //    }
            //}

            if (outdoorAreas)
            {
                //-- Intersecting climbing areas
                AddSpecificAreaTypes(collection, relatedAreas, CfType.ClimbingArea, "ca");
            }

            //-- We want to do cities last so that they (the city icons) render on top
            if (cities)
            {
                //-- Intersecting cities
                AddSpecificAreaTypes(collection, relatedAreas, CfType.City, "cty");
            }
        }
コード例 #3
0
ファイル: MapSvc.cs プロジェクト: yogee88/Climbfind_v4_2011
        /// <summary>
        ///
        /// </summary>
        /// <param name="mapItemCollection"></param>
        /// <returns></returns>
        private Message ReturnMapItemCollectionAsJson(MapItemCollection mapItemCollection)
        {
            WebOperationContext.Current.OutgoingResponse.ContentType = "application/json";
            JavaScriptSerializer serializer = new JavaScriptSerializer();

            //-- remove this line!
            serializer.MaxJsonLength = 4097152;

            var output = serializer.Serialize(mapItemCollection);

            return(WebOperationContext.Current.CreateTextResponse(output));
        }
コード例 #4
0
        public MapItemCollection GetAreaForNewOutdoorClimbingLocationMapItems(Area area)
        {
            MapItemCollection collection = new MapItemCollection();

            collection.AppendGeographyToGeoMapItemCollection(area.Geo, area.Name);

            var locations        = locRepo.GetLocationsOfArea(area.ID);
            var outdoorLocations = locations.Where(l => l.Type.ToPlaceCateogry() == PlaceCategory.IndoorClimbing).ToList();

            AddLocationsToCollection(collection, outdoorLocations, true, true, false, false);

            return(collection);
        }
コード例 #5
0
        public void Clusterize(IEnumerable <MapItem> sourceItems, MapViewport viewport, bool sourceChanged)
        {
            Thread clusteringThread = new Thread(() => {
                isBusy = true;
                if (sourceChanged)
                {
                    currentItems = ClusterizeImpl(sourceItems);
                    owner.OnClustered();
                }
                isBusy = false;
            });

            clusteringThread.Start();
        }
        private void GenerateVectorItems(MapItemCollection col)
        {
            int    width       = 5;
            double singlePower = maxPower / rectNumber;

            for (int i = 0; i < rectNumber; i++)
            {
                MapPolygon polygon = CreatePolygon(i * singlePower,
                                                   new GeoPoint[] { new GeoPoint(0, width * i),
                                                                    new GeoPoint(0, width * (i + 1)),
                                                                    new GeoPoint(40, width * (i + 1)),
                                                                    new GeoPoint(40, width * i),
                                                                    new GeoPoint(0, width * i) });
                col.Add(polygon);
            }
        }
コード例 #7
0
        public MapItemCollection GetAreaEditMapItems(Area area)
        {
            //-- Edit is a bit different, we don't want to reduce the polygon so we use the normal constructor
            MapItemCollection collection = new MapItemCollection();

            collection.AppendGeographyToGeoMapItemCollection(area.Geo, area.Name);

            var locations        = locRepo.GetLocationsOfArea(area.ID);
            var indoorLocations  = locations.Where(l => l.Type.ToPlaceCateogry() == PlaceCategory.IndoorClimbing).ToList();
            var outdoorLocations = locations.Where(l => l.Type.ToPlaceCateogry() == PlaceCategory.OutdoorClimbing).ToList();

            AddLocationsToCollection(collection, indoorLocations, true, true, false, false);
            AddLocationsToCollection(collection, outdoorLocations, true, true, false, false);

            return(collection);
        }
コード例 #8
0
        public MapItemCollection GetCountryMapItems(Country country)
        {
            MapItemCollection collection = CreateMapItemCollectionWithReducedParentItem(country);

            var areas = areaRepo.GetCitiesAndMajorClimbingAreasOfCountry(country.ID);

            var cities        = areas.Where(c => c.Type == CfType.City);
            var climbingAreas = areas.Where(c => c.Type == CfType.ClimbingArea).ToList().RemoveAllChildAreas();

            //-- We actually only want to display cities and climbing areas in the country view
            AddSpecificAreaTypes(collection, climbingAreas, CfType.ClimbingArea, "ca");
            //-- Also we want to do cities last because they should appear on the top
            AddSpecificAreaTypes(collection, cities, CfType.City, "cty");

            return(collection);
        }
コード例 #9
0
        /// <summary>
        /// Map Item Collections
        /// </summary>
        /// <param name="area"></param>
        /// <returns></returns>
        private MapItemCollection CreateMapItemCollectionWithReducedParentItem(IArea area)
        {
            MapItemCollection collection = new MapItemCollection();
            SqlGeography      reducedGeo = area.Geo;

            if (area.GeoReduceThreshold > 5000)
            {
                reducedGeo = area.Geo.STBuffer(4000).Reduce(area.GeoReduceThreshold - 5000);
            }
            else if (area.GeoReduceThreshold > 0)
            {
                reducedGeo = area.Geo.Reduce(area.GeoReduceThreshold);
            }
            collection.AppendGeographyToGeoMapItemCollection(reducedGeo, area.Name);
            return(collection);
        }
コード例 #10
0
        private void AddLocationsToCollection(MapItemCollection collection, IList <Location> locations, bool indoor, bool outdoor, bool business, bool meetingPoints)
        {
            //-- Return Indoor Climbing
            foreach (var l in locations)
            {
                var cat = l.Type.ToPlaceCateogry();

                if (indoor && (cat == PlaceCategory.IndoorClimbing))
                {
                    collection.AddPoint(l.Name, l.Description, l.SlugUrl, l.Avatar, "id", l.Latitude, l.Longitude);
                }
                if (outdoor && (cat == PlaceCategory.OutdoorClimbing))
                {
                    collection.AddPoint(l.Name, l.Description, l.SlugUrl, l.Avatar, "od", l.Latitude, l.Longitude);
                }
            }
        }
コード例 #11
0
        MapItemCollection ClusterizeImpl(IEnumerable <MapItem> sourceItems)
        {
            // Separate localizable and non localizable items.
            List <MapItem> nonLocalizableItems = new List <MapItem>();
            List <Cluster> clusters            = new List <Cluster>();

            foreach (MapItem item in sourceItems)
            {
                ISupportCoordLocation localizableItem = item as ISupportCoordLocation;
                if (localizableItem != null)
                {
                    clusters.Add(Cluster.Initialize(localizableItem));
                }
                else
                {
                    nonLocalizableItems.Add(item);
                }
            }

            // Arrange initial clusters in increasing order of distance to a closest cluster.
            clusters = Arrange(clusters);

            // Aggregate localizable items.
            while (clusters.Count > ClusterCount)
            {
                MergeCloserstClusters(ref clusters);
            }

            // Convert internal cluster helpers to Map items.
            MapItemCollection clusterRepresentatives = new MapItemCollection(owner);

            for (int i = 0; i < clusters.Count; ++i)
            {
                Cluster cluster        = clusters[i];
                MapDot  representative = new MapDot()
                {
                    Location = new GeoPoint(cluster.CenterPoint.Y, cluster.CenterPoint.X), Size = 100
                };
                representative.ClusteredItems       = cluster.Items.Select(item => item as MapItem).ToList();
                representative.TitleOptions.Pattern = representative.ClusteredItems.Count.ToString();
                clusterRepresentatives.Add(representative);
            }
            clusterRepresentatives.AddRange(nonLocalizableItems);
            return(clusterRepresentatives);
        }
コード例 #12
0
        public MapItemCollection GetCityMapItems(Area area)
        {
            MapItemCollection collection = CreateMapItemCollectionWithReducedParentItem(area);

            var locations       = locRepo.GetLocationsOfArea(area.ID);
            var indoorLocations = locations.Where(l => l.Type.ToPlaceCateogry() == PlaceCategory.IndoorClimbing).ToList();

            AddLocationsToCollection(collection, indoorLocations, true, false, false, false);

            var areas         = areaRepo.GetIntersectingAreasWithGeoInflate(area.ID);
            var climbingAreas = areas.Where(c => c.Type == CfType.ClimbingArea).ToList();

            climbingAreas = area.RemoveIntersectingNonChildAreas(climbingAreas).RemoveAllChildAreas();

            //-- We actually only want to display cities and climbing areas in the country view
            AddSpecificAreaTypes(collection, climbingAreas, CfType.ClimbingArea, "ca");

            return(collection);
        }
コード例 #13
0
        public ActionResult AreaNewSubAreaToArea(string countryUrlPart, string areaUrlPart)
        {
            var parentArea = geoSvc.GetArea(country.ID, areaUrlPart);

            if (parentArea == null)
            {
                return(PlaceNotFound());
            }

            List <Area> existingAreasOfType = geoSvc.GetIntersectingAreas(parentArea).Where(
                a => a.Type == CfType.ClimbingArea).OrderBy(a => a.Name).ToList();

            InitializeAreaNewViewData(parentArea, CfType.ClimbingArea, existingAreasOfType);

            var mapCollection = new MapItemCollection();

            mapCollection.AppendGeographyToGeoMapItemCollection(parentArea.Geo, "shp");
            ViewBag.ParentAreaCoordinates = mapCollection.Items[0].C;

            return(View("AreaNew"));
        }
コード例 #14
0
ファイル: Map.cs プロジェクト: ooooolivia/runtime
 public MapItemEnumerator(MapItemCollection mapCollection)
 {
     _mapItemCollection = mapCollection;
 }
コード例 #15
0
        public ActionResult AreaNewSubAreaToArea(string countryUrlPart, string areaUrlPart)
        {
            var parentArea = geoSvc.GetArea(country.ID, areaUrlPart);
            if (parentArea == null) { return PlaceNotFound(); }

            List<Area> existingAreasOfType = geoSvc.GetIntersectingAreas(parentArea).Where(
                a => a.Type == CfType.ClimbingArea).OrderBy(a => a.Name).ToList();

            InitializeAreaNewViewData(parentArea, CfType.ClimbingArea, existingAreasOfType);

            var mapCollection = new MapItemCollection();
            mapCollection.AppendGeographyToGeoMapItemCollection(parentArea.Geo, "shp");
            ViewBag.ParentAreaCoordinates = mapCollection.Items[0].C;

            return View("AreaNew");
        }