Sfoglia il codice sorgente

Correccion parseo geolocalizacion

ricardo valls 3 anni fa
parent
commit
834200b3d7

+ 37 - 12
WorkerService1/WebApplication3/Clases/Parser.cs Vedi File

@@ -632,29 +632,54 @@ namespace WebApplication3.Clases
632 632
             return piezometria;
633 633
         }
634 634
 
635
-        public void GetGeolocalizationFromFile(string file,out string worldX,out string worldY, out string angle, out string length, out string heigth)
635
+        public void GetGeolocalizationFromFile(string file,out string worldX,out string worldY, out string angle, out string length, out string height)
636 636
         {
637
+            string[] world_origin_x, world_origin_y, modelAngle, modelLength, modelHeight;
637 638
 
639
+            worldX = worldY = angle = length = height = "";
638 640
             string text = File.ReadAllText(file);
639 641
 
640 642
             List<string> data = text.Split("\r\n", StringSplitOptions.RemoveEmptyEntries).ToList();
641 643
             //string geolocationData = data[2];
642 644
             string geolocation_line = data.Find(x => x.Contains("<Georeference"));
643 645
 
644
-            string[] geolocation_data = geolocation_line.Split(" ", StringSplitOptions.RemoveEmptyEntries);
645
-            string[] world_origin_x = geolocation_data[3].Split("World_Origin_X=", StringSplitOptions.RemoveEmptyEntries);
646
-            string[] world_origin_y = geolocation_data[4].Split("World_Origin_Y=", StringSplitOptions.RemoveEmptyEntries);
647
-            string[] modelAngle = geolocation_data[5].Split("Angle=", StringSplitOptions.RemoveEmptyEntries);
648
-            string[] modelLength = geolocation_data[6].Split("Length=", StringSplitOptions.RemoveEmptyEntries);
649
-            string[] modelHeigth = geolocation_data[7].Split("Height=", StringSplitOptions.RemoveEmptyEntries);
646
+            List<string> geolocation_data = geolocation_line.Split(" ", StringSplitOptions.RemoveEmptyEntries).ToList();
650 647
 
648
+            string wox = geolocation_data.Find(x => x.Contains("World_Origin_X="));
649
+            if(wox != null)
650
+            {
651
+                world_origin_x = wox.Split("World_Origin_X=", StringSplitOptions.RemoveEmptyEntries);
652
+                worldX = world_origin_x[0].Replace("\"", string.Empty);
653
+            }
654
+
655
+            string woy = geolocation_data.Find(x => x.Contains("World_Origin_Y="));
656
+            if (wox != null)
657
+            {
658
+                world_origin_y = woy.Split("World_Origin_Y=", StringSplitOptions.RemoveEmptyEntries);
659
+                worldY = world_origin_y[0].Replace("\"", string.Empty);
660
+            }
661
+
662
+            string magl = geolocation_data.Find(x => x.Contains("Angle="));
663
+            if (magl != null)
664
+            {
665
+                modelAngle = magl.Split("Angle=", StringSplitOptions.RemoveEmptyEntries);
666
+                angle = modelAngle[0].Replace("\"", string.Empty);
667
+            }
651 668
 
652
-            worldX = world_origin_x[0].Replace("\"", string.Empty);
653
-            worldY = world_origin_y[0].Replace("\"", string.Empty);
654
-            angle = modelAngle[0].Replace("\"",string.Empty);
655
-            length = modelLength[0].Replace("\"", string.Empty);
656
-            heigth = modelHeigth[0].Replace("\"", string.Empty);
669
+            string mlgth = geolocation_data.Find(x => x.Contains("Length="));
670
+            if (mlgth != null)
671
+            {
672
+                modelLength = mlgth.Split("Length=", StringSplitOptions.RemoveEmptyEntries);
673
+                length = modelLength[0].Replace("\"", string.Empty);
674
+            }
657 675
 
676
+            string mhei = geolocation_data.Find(x => x.Contains("Height="));
677
+            if (mhei != null)
678
+            {
679
+                modelHeight = mhei.Split("Height=", StringSplitOptions.RemoveEmptyEntries);
680
+                height = modelHeight[0].Replace("\"", string.Empty);
681
+                height = height.Replace("/>", string.Empty);
682
+            }
658 683
         }
659 684
 
660 685
         public WellData[] parseWellCSV(string file)

+ 11 - 11
WorkerService1/WebApplication3/Controllers/AcuiferoController.cs Vedi File

@@ -187,16 +187,16 @@ namespace WebApplication3.Controllers
187 187
             List<string> files;
188 188
             Parser parser = new();
189 189
 
190
-            //try
191
-            //{
192
-            //    byte[] tempBytes = Convert.FromBase64String(datos.Fichero.Base64);
193
-            //    System.IO.File.WriteAllBytes(Constants.PathZip + datos.Fichero.Nombre, tempBytes);
190
+            try
191
+            {
192
+                byte[] tempBytes = Convert.FromBase64String(datos.Fichero.Base64);
193
+                System.IO.File.WriteAllBytes(Constants.PathZip + datos.Fichero.Nombre, tempBytes);
194 194
 
195
-            //}
196
-            //catch (Exception ex)
197
-            //{
198
-            //    return Problem(ex.Message);
199
-            //}
195
+            }
196
+            catch (Exception ex)
197
+            {
198
+                return Problem(ex.Message);
199
+            }
200 200
 
201 201
             acuifero.Fichero = datos.Fichero.Nombre;
202 202
 
@@ -230,8 +230,8 @@ namespace WebApplication3.Controllers
230 230
                 await PostSimulationZero(sim);
231 231
 
232 232
                 //2- Obtenemos nombre de los ficheros de pozos y recargas 
233
-                pozoFile = files.Find(x => x.Contains(".VMW"));
234
-                recargaFile = files.Find(x => x.Contains(".VMP"));
233
+                pozoFile = files.Find(x => x.Contains(".VMW") || x.Contains(".vmw"));
234
+                recargaFile = files.Find(x => x.Contains(".VMP") || x.Contains(".vmp"));
235 235
 
236 236
                 //3- Parseamos pozos
237 237
                 if (System.IO.File.Exists(pozoFile))