Exemplo n.º 1
0
        /* Creates the geofence of the lot
         */
        public void CreateGeoFence()
        {
            mGeoFence = new GeoPoly(GetName());

            for (int i = 0; i < Locations.Count(); i++)
            {
                int i2 = (i + 1) % Locations.Count();
                mGeoFence.AddGeoLine(Locations.ElementAt(i), Locations.ElementAt(i2));
            }
        }
Exemplo n.º 2
0
        /** DO NOT USE WITH API: ONLY TO BE USED WITH TEST .JSON FILES
         * Gets the campuses from the campuses.json file, converts them to a campus object, then creates
         * a polygon object to visually represent it and adds it to the map.
         */
        public Campus AddCampus(string name)
        {
            var    assembly = typeof(MapPage).GetTypeInfo().Assembly;
            Stream stream   = assembly.GetManifestResourceStream("GMPark.campuses.json");
            string text     = "";

            using (var reader = new System.IO.StreamReader(stream))
            {
                text = reader.ReadToEnd();
            }

            List <Campus> campuses = JsonConvert.DeserializeObject <List <Campus> >(text);

            foreach (Campus campus in campuses)
            {
                if (name == campus.GetName())
                {
                    var polygon = new Polygon();
                    polygon.IsClickable = true;
                    polygon.StrokeColor = Color.Blue;
                    polygon.StrokeWidth = 1f;
                    polygon.FillColor   = Color.FromRgba(0, 0, 255, 64);
                    var campusGeofence = new GeoPoly(campus.GetName());

                    for (int i = 0; i < campus.Locations.Count(); i++)
                    {
                        polygon.Positions.Add(new Position(campus.Locations[i].Lat, campus.Locations[i].Long));

                        int i2 = (i + 1) % campus.Locations.Count();
                        campusGeofence.AddGeoLine(campus.Locations.ElementAt(i), campus.Locations.ElementAt(i2));
                    }

                    Polygons.Add(polygon);
                    mCampusGeofences.Add(campusGeofence);
                    mCampuses.Add(campus);
                    return(campus);
                }
            }

            return(null);
        }
Exemplo n.º 3
0
        /** DO NOT USE WITH API: ONLY TO BE USED WITH TEST .JSON FILES
         * Create a polygon object to visually represent it and adds it to the map.
         * Parameters: List<Campus> (all the campus objects that are to be created)
         */
        public void AddCampuses(List <Campus> campuses)
        {
            foreach (Campus campus in campuses)
            {
                var polygon = new Polygon();
                polygon.IsClickable = true;
                polygon.StrokeColor = Color.Blue;
                polygon.StrokeWidth = 1f;
                polygon.FillColor   = Color.FromRgba(0, 0, 255, 64);
                var campusGeofence = new GeoPoly(campus.GetName());

                for (int i = 0; i < campus.Locations.Count(); i++)
                {
                    polygon.Positions.Add(new Position(campus.Locations[i].Lat, campus.Locations[i].Long));

                    int i2 = (i + 1) % campus.Locations.Count();
                    campusGeofence.AddGeoLine(campus.Locations.ElementAt(i), campus.Locations.ElementAt(i2));
                }

                Polygons.Add(polygon);
                mCampusGeofences.Add(campusGeofence);
                mCampuses.Add(campus);
            }
        }