Пример #1
0
        public async Task <List <OsmGeo> > DownloadArea(double leftLong, double bottomLat, double rightLong, double topLat)
        {
            AzureService wc = new AzureService();

            string res =
                await wc.DownloadStringAsync(
                    $"http://overpass.osm.rambler.ru/cgi/xapi_meta?*[bbox={leftLong}, {bottomLat}, {rightLong}, {topLat}]", 120000);

            if (res == null)
            {
                throw new Exception("Reading unsuccessful");
            }
            string path = Environment.ExternalStorageDirectory + Java.IO.File.Separator + "temporary_file.txt";

            Java.IO.File file = new Java.IO.File(path);
            if (file.Exists())
            {
                file.Delete();
            }
            using (StreamWriter bytes = new StreamWriter(path, true))
            {
                bytes.WriteLine(res);
            }
            return(Deserialize(res));
        }
Пример #2
0
        public async Task <Bitmap> DownloadTile(int zoomLevel, double x, double y)
        {
            AzureService service = new AzureService();
            Stream       stream  = service.CreateBitmap($"http://b.tile.openstreetmap.org/{zoomLevel}/{x}/{y}.png");

            byte[] imageBytes = new byte[stream.Length];
            stream.Read(imageBytes, 0, (int)stream.Length);
            BitmapFactory.Options options = new BitmapFactory.Options();
            options.InPurgeable       = true;
            options.InInputShareable  = true;
            options.InPreferredConfig = Bitmap.Config.Argb8888;
            return(BitmapFactory.DecodeByteArray(imageBytes, 0, imageBytes.Length, options));
        }
Пример #3
0
 public async Task UploadPoint(double lat, double longitude)
 {
     Coordinates coordinates = new Coordinates()
     {
         CreatorId             = Guid.Parse("3133C939-CA10-4F6F-9FEE-BB647AF50BF7"),
         CrowdsourcedPlaceType = 1,
         Point = new Point()
         {
             coordinates = new List <double> {
                 lat, longitude
             },
         }
     };
     AzureService service = new AzureService();
     await service.PostDataAsync <Coordinates>("http://spaceherders.northeurope.cloudapp.azure.com/api/CrowdsourcedPlace", coordinates);
 }
Пример #4
0
        private async Task <string> GetJsonAsync(string url, int timeout = 15000, CancellationTokenSource cancelToken = null)
        {
            try
            {
                string       json;
                AzureService wc = new AzureService();
                json = await wc.DownloadStringAsync(url, timeout, cancelToken);

                json = json.Replace("Date(-", "Date(");

                return(json);
            }
            catch (Exception exception)
            {
                return("Error");
            }
        }