Region2LongitudeLatitudeTranslator.cs 1.0 KB

123456789101112131415161718192021222324252627282930
  1. using Newtonsoft.Json.Linq;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. namespace TEAMModelOS.SDK.DI
  9. {
  10. public class Region2LongitudeLatitudeTranslator
  11. {
  12. public readonly JArray regionJson;
  13. public Region2LongitudeLatitudeTranslator(string configPath)
  14. {
  15. if (configPath == null) throw new ArgumentNullException(nameof(configPath));
  16. StreamReader streamReader = new StreamReader(new FileStream(Path.Combine(configPath , "latlng.json"), FileMode.Open, FileAccess.Read, FileShare.ReadWrite), Encoding.UTF8);
  17. StringBuilder stringBuilder = new StringBuilder();
  18. string text;
  19. while ((text = streamReader.ReadLine()) != null)
  20. {
  21. stringBuilder.Append(text.ToString());
  22. }
  23. streamReader.Close();
  24. string input = stringBuilder.ToString();
  25. regionJson= JArray.Parse(input);
  26. }
  27. }
  28. }