Exemplo n.º 1
0
        private void Hospitals()
        {
            XDocument xdoc = XDocument.Load(@"doc.kml");
            BallaratMinuteModel model = new BallaratMinuteModel();
            model.POITypes.AddOrUpdate(p => p.Name, new POIType() { Name = "Hospital" });
            model.SaveChanges();

            var query = xdoc.Root
               .Element("Document")
               .Elements("Placemark")
               .Select(x => new  // I assume you've already got this
               {
                   Name = x.Element("name").Value,
                   Description = x.Element("description").Value,
                   // etc
                   Coords = x.Element("Point").Element("coordinates").Value
               });

            foreach (var placeMark in query)
            {
                CQ desc = placeMark.Description;

                var test = desc["td"];
                var t2 = test.Single(i => i.InnerText == "Address");
                var addr = t2.NextSibling.InnerText;

                var t3 = test.Single(i => i.InnerText == "Town");
                var town = t3.NextSibling.InnerText;

                var t4 = test.Single(i => i.InnerText == "Postcode");
                var postcode = t4.NextSibling.InnerText;

               var address = addr + ", " + town + " " + postcode;

                model.PointsOfInterest.AddOrUpdate(i => i.Name, new PointOfInterest()
                {
                    TypeID = model.POITypes.Single(j => j.Name == "Hospital").ID,
                    Coordinates =
                        DbGeography.FromText("POINT(" + placeMark.Coords.Split(',')[0] + " " +
                                             placeMark.Coords.Split(',')[1] + ")"),
                    Desc = address,
                    Name = placeMark.Name
                });
                model.SaveChanges();
            }
        }
Exemplo n.º 2
0
 // POST api/values
 public void Post([FromBody]VicPoint value)
 {
     //feature_ty": "PG-Skate Parks",
     BallaratMinuteModel model = new BallaratMinuteModel();
     var poiType = new POIType()
     {
         Name = "B-Child Minding Playground"
     };
     model.POITypes.AddOrUpdate(p => p.Name, poiType);
     model.SaveChanges();
     model.PointsOfInterest.AddOrUpdate(new PointOfInterest()
     {
         Name = "Alfredton Pre School",//Site
         Desc = "Alfredton Pre School Play Equipment\n6-8 Balyarta Street\nAlfredton",
         TypeID = poiType.ID,
         Coordinates = DbGeography.FromText("POINT(143.80650095599 -37.5523078953505)")
     });
     model.SaveChanges();
 }
Exemplo n.º 3
0
        private void BusShelters()
        {
            //
            string json;
            using (WebClient client = new WebClient())
            {
                json =
                    client.DownloadString(
                        "https://data.gov.au/dataset/bea6519d-2785-4435-9d1e-a7ca070d675d/resource/26bb3915-a9a9-408f-9496-e1671517886a/download/busshelters.json");
            }

            BallaratBusShelter m = JsonConvert.DeserializeObject<BallaratBusShelter>(json);
            BallaratMinuteModel model = new BallaratMinuteModel();
            //List<string> features = m.features.Select(feature => feature.properties.PlayType).ToList().Distinct().OrderBy(i => i).ToList();
            foreach (var feature in m.features)
            {
                model.POITypes.AddOrUpdate(p => p.Name, new POIType() { Name = feature.properties.Feature_Ty });
                model.SaveChanges();

                if (feature.geometry == null) continue;
                model.PointsOfInterest.AddOrUpdate(i => i.Name, new PointOfInterest()
                {
                    TypeID = model.POITypes.Single(j => j.Name == feature.properties.Feature_Ty).ID,
                    Coordinates =
                        DbGeography.FromText("POINT(" + feature.geometry.coordinates[0] + " " +
                                             feature.geometry.coordinates[1] + ")"),
                    Desc = feature.properties.Feature_Lo,
                    Name = feature.properties.Site_Name
                });
                model.SaveChanges();
            }
        }
Exemplo n.º 4
0
        private void Childcare()
        {
            string json;
            using (WebClient client = new WebClient())
            {
                json =
                    client.DownloadString(
                        "https://data.gov.au/dataset/c8642f6b-0c28-48d2-867f-4c95ed64a84a/resource/76100de9-9c7d-4c9c-bdf7-a5967fad7863/download/ballaratchildcarecentres.json");
            }

            var m = JsonConvert.DeserializeObject<List<BallaratChildCare>>(json);
            BallaratMinuteModel model = new BallaratMinuteModel();
            //List<string> features = m.features.Select(feature => feature.properties.PlayType).ToList().Distinct().OrderBy(i => i).ToList();

            model.POITypes.AddOrUpdate(p => p.Name, new POIType() { Name = "Childcare Centre" });
            model.SaveChanges();

            foreach (var feature in m)
            {
                model.PointsOfInterest.AddOrUpdate(i => i.Name, new PointOfInterest()
                {
                    TypeID = model.POITypes.Single(j => j.Name == "Childcare Centre").ID,
                    Coordinates =
                        DbGeography.FromText("POINT(" + feature.lon + " " +
                                             feature.lat + ")"),
                    Desc = feature.address,
                    Name = feature.name
                });
                model.SaveChanges();
            }
        }
Exemplo n.º 5
0
        //private static void LicensedVenues()
        //{
        //    //
        //    string csv;
        //    using (WebClient client = new WebClient())
        //    {
        //        csv =
        //            client.DownloadString(
        //                "https://www.data.vic.gov.au/data/dataset/62d969b6-2986-4d8f-927f-1f577be85994/resource/a632e594-8de3-428d-aac4-ab601db1177d/download/.fileslicences.csv");
        //    }
        //    var csvFile = new CsvReader(csv);
        //    var records = csvFile.GetRecords<BallaratLicense>();
        //}
        //private class BallaratLicense
        //{
        //    public int LicenceNo;
        //    public int LicenceType;
        //    public int PremisesName;
        //    public int Licensee;
        //    public int Address1;
        //    public int Address2;
        //    public int Suburb;
        //    public int Postcode;
        //}
        private static void Toilets()
        {
            string json;
            using (WebClient client = new WebClient())
            {
                json =
                    client.DownloadString(
                        "http://data.gov.au/geoserver/ballarat-public-toilets/wfs?request=GetFeature&typeName=4f875c86_2a8c_4daf_b40d_dca04aab49ea&outputFormat=json");
            }

            BallaratToilet m = JsonConvert.DeserializeObject<BallaratToilet>(json);
            BallaratMinuteModel model = new BallaratMinuteModel();
            //List<string> features = m.features.Select(feature => feature.properties.PlayType).ToList().Distinct().OrderBy(i => i).ToList();
            foreach (var feature in m.features)
            {
                model.POITypes.AddOrUpdate(p => p.Name, new POIType() { Name = feature.properties.type });
                model.SaveChanges();

                if (feature.geometry == null) continue;
                model.PointsOfInterest.AddOrUpdate(i => i.Name, new PointOfInterest()
                {
                    TypeID = model.POITypes.Single(j => j.Name == feature.properties.type).ID,
                    Coordinates =
                        DbGeography.FromText("POINT(" + feature.geometry.coordinates[0] + " " +
                                             feature.geometry.coordinates[1] + ")"),
                    Desc = feature.properties.location,
                    Name = feature.properties.site
                });
                model.SaveChanges();
            }
        }
Exemplo n.º 6
0
        private static void PlayGrounds()
        {
            string json;
            using (WebClient client = new WebClient())
            {
                json =
                    client.DownloadString(
                        "http://data.gov.au/dataset/a9b248c1-2078-45fa-b9c6-b2ae562c87b2/resource/693b8663-efd6-4583-9dd6-7a3793e54bae/download/BallaratPlaygrounds.geojson");
            }

            BallaratPlayground m = JsonConvert.DeserializeObject<BallaratPlayground>(json);
            BallaratMinuteModel model = new BallaratMinuteModel();
            //List<string> features = m.features.Select(feature => feature.properties.PlayType).ToList().Distinct().OrderBy(i => i).ToList();
            foreach (var feature in m.features)
            {
                model.POITypes.AddOrUpdate(p => p.Name, new POIType() {Name = feature.properties.PlayType});
                model.SaveChanges();

                if (feature.geometry == null) continue;
                model.PointsOfInterest.AddOrUpdate(i => i.Name, new PointOfInterest()
                {
                    TypeID = model.POITypes.Single(j => j.Name == feature.properties.PlayType).ID,
                    Coordinates =
                        DbGeography.FromText("POINT(" + feature.geometry.coordinates[0] + " " +
                                             feature.geometry.coordinates[1] + ")"),
                    Desc = feature.properties.Location,
                    Name = feature.properties.Site
                });
                model.SaveChanges();
            }
        }
Exemplo n.º 7
0
        private static void Kindergartens()
        {
            string json;
            using (WebClient client = new WebClient())
            {
                json =
                    client.DownloadString(
                        "http://data.gov.au/geoserver/ballarat-kindergartens/wfs?request=GetFeature&typeName=7d2e9e5e_f653_487f_a272_1c54d7a37e47&outputFormat=json");
            }

            BallaratKindergarten m = JsonConvert.DeserializeObject<BallaratKindergarten>(json);
            BallaratMinuteModel model = new BallaratMinuteModel();
            //List<string> features = m.features.Select(feature => feature.properties.PlayType).ToList().Distinct().OrderBy(i => i).ToList();
            model.POITypes.AddOrUpdate(p => p.Name, new POIType() { Name = "Kindergarten" });
            model.SaveChanges();
            foreach (var feature in m.features)
            {

                if (feature.geometry == null) continue;
                model.PointsOfInterest.AddOrUpdate(i => i.Name, new PointOfInterest()
                {
                    TypeID = model.POITypes.Single(j => j.Name == "Kindergarten").ID,
                    Coordinates =
                        DbGeography.FromText("POINT(" + feature.geometry.coordinates[0] + " " +
                                             feature.geometry.coordinates[1] + ")"),
                    Desc = feature.properties.address,
                    Name = feature.properties.name
                });
                model.SaveChanges();
            }
        }
Exemplo n.º 8
0
        private static void EducationFacilities()
        {
            string json;
            using (WebClient client = new WebClient())
            {
                json =
                    client.DownloadString(
                        "http://data.gov.au/geoserver/ballarat-education-facilities/wfs?request=GetFeature&typeName=02dc15c8_cd31_4b2f_abd0_276e59e391c3&outputFormat=json");
            }

            BallaratEducationFacility m = JsonConvert.DeserializeObject<BallaratEducationFacility>(json);
            BallaratMinuteModel model = new BallaratMinuteModel();
            //List<string> features = m.features.Select(feature => feature.properties.PlayType).ToList().Distinct().OrderBy(i => i).ToList();
            foreach (var feature in m.features)
            {
                model.POITypes.AddOrUpdate(p => p.Name, new POIType() { Name = feature.properties.service });
                model.SaveChanges();

                if (feature.geometry == null) continue;
                model.PointsOfInterest.AddOrUpdate(i => i.Name, new PointOfInterest()
                {
                    TypeID = model.POITypes.Single(j => j.Name == feature.properties.service).ID,
                    Coordinates =
                        DbGeography.FromText("POINT(" + feature.geometry.coordinates[0] + " " +
                                             feature.geometry.coordinates[1] + ")"),
                    Desc = feature.properties.location,
                    Name = feature.properties.name
                });
                model.SaveChanges();
            }
        }
Exemplo n.º 9
0
        private static void Centrelink()
        {
            string csv;
            using (WebClient client = new WebClient())
            {
                csv =
                    client.DownloadString(
                        "http://data.gov.au/dataset/70c2b2fe-2a32-450e-98dc-453fe4a02aae/resource/5a45d7b2-8579-425b-bb46-53a0e0bfa053/download/Centrelink-Office-Locations-as-at-4-June-2015.csv");
            }
            using (TextReader sr = new StringReader(csv))
            {
                BallaratMinuteModel model = new BallaratMinuteModel();
                //List<string> features = m.features.Select(feature => feature.properties.PlayType).ToList().Distinct().OrderBy(i => i).ToList();

                model.POITypes.AddOrUpdate(p => p.Name, new POIType() { Name = "Centrelink" });
                model.SaveChanges();

                var csvFile = new CsvReader(sr);
                while (csvFile.Read())
                {
                    model.PointsOfInterest.AddOrUpdate(i => i.Name, new PointOfInterest()
                    {
                        TypeID = model.POITypes.Single(j => j.Name == "Centrelink").ID,
                        Coordinates =
                            DbGeography.FromText("POINT(" + csvFile.GetField<string>("LONGITUDE") + " " +
                                                    csvFile.GetField<string>("LATITUDE") + ")"),
                        Desc = csvFile.GetField<string>("ADDRESS") + ", " + csvFile.GetField<string>("SUBURB") + " " + csvFile.GetField<string>("POSTCODE"),
                        Name = csvFile.GetField<string>("OFFICE TYPE") + " - " + csvFile.GetField<string>("SITE NAME")
                    });
                    model.SaveChanges();
                }
            }
        }