RealWorldTerrainGooglePlaceDetailsResult.cs 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. /* INFINITY CODE 2013-2019 */
  2. /* http://www.infinity-code.com */
  3. using InfinityCode.RealWorldTerrain.XML;
  4. using UnityEngine;
  5. namespace InfinityCode.RealWorldTerrain.Webservices.Results
  6. {
  7. /// <summary>
  8. /// Result of Google Maps Place Details query.
  9. /// </summary>
  10. public class RealWorldTerrainGooglePlaceDetailsResult
  11. {
  12. /// <summary>
  13. /// Human-readable address of this place.\n
  14. /// Often this address is equivalent to the "postal address," which sometimes differs from country to country.
  15. /// </summary>
  16. public string formatted_address;
  17. /// <summary>
  18. /// Phone number in its local format.\n
  19. /// For example, the formatted_phone_number for Google's Sydney, Australia office is (02) 9374 4000.
  20. /// </summary>
  21. public string formatted_phone_number;
  22. /// <summary>
  23. /// Geographic coordinates of place.
  24. /// </summary>
  25. public Vector2 location;
  26. /// <summary>
  27. /// URL of a suggested icon which may be displayed to the user when indicating this result on a map.
  28. /// </summary>
  29. public string icon;
  30. /// <summary>
  31. /// unique stable identifier denoting this place.\n
  32. /// This identifier may not be used to retrieve information about this place, but can be used to consolidate data about this place, and to verify the identity of a place across separate searches.\n
  33. /// As IDs can occasionally change, it's recommended that the stored ID for a place be compared with the ID returned in later Details requests for the same place, and updated if necessary.\n
  34. /// Note: The id is now deprecated in favor of place_id.
  35. /// </summary>
  36. public string id;
  37. /// <summary>
  38. /// Phone number in international format.\n
  39. /// International format includes the country code, and is prefixed with the plus (+) sign.\n
  40. /// For example, the international_phone_number for Google's Sydney, Australia office is +61 2 9374 4000.
  41. /// </summary>
  42. public string international_phone_number;
  43. /// <summary>
  44. /// Human-readable name for the returned result.\n
  45. /// For establishment results, this is usually the canonicalized business name.
  46. /// </summary>
  47. public string name;
  48. /// <summary>
  49. /// Reference to XML node.
  50. /// </summary>
  51. public RealWorldTerrainXML node;
  52. /// <summary>
  53. /// Array of photo objects, each containing a reference to an image.\n
  54. /// A Place Details request may return up to ten photos.
  55. /// </summary>
  56. public RealWorldTerrainPlacesResult.Photo[] photos;
  57. /// <summary>
  58. /// A textual identifier that uniquely identifies a place.
  59. /// </summary>
  60. public string place_id;
  61. /// <summary>
  62. /// The price level of the place, on a scale of 0 to 4.
  63. /// The exact amount indicated by a specific value will vary from region to region.
  64. /// Price levels are interpreted as follows:
  65. /// -1 - Unknown
  66. /// 0 — Free
  67. /// 1 — Inexpensive
  68. /// 2 — Moderate
  69. /// 3 — Expensive
  70. /// 4 — Very Expensive
  71. /// </summary>
  72. public int price_level = -1;
  73. /// <summary>
  74. /// Place's rating, from 1.0 to 5.0, based on aggregated user reviews.
  75. /// </summary>
  76. public float rating;
  77. /// <summary>
  78. /// Unique token that you can use to retrieve additional information about this place in a Place Details request. \n
  79. /// Although this token uniquely identifies the place, the converse is not true. \n
  80. /// A place may have many valid reference tokens. \n
  81. /// It's not guaranteed that the same token will be returned for any given place across different searches. \n
  82. /// Note: The reference is now deprecated in favor of place_id.
  83. /// </summary>
  84. public string reference;
  85. /// <summary>
  86. /// Array of feature types describing the given result. \n
  87. /// XML responses include multiple type elements if more than one type is assigned to the result.
  88. /// </summary>
  89. public string[] types;
  90. /// <summary>
  91. /// URL of the official Google page for this place.\n
  92. /// This will be the establishment's Google+ page if the Google+ page exists, otherwise it will be the Google-owned page that contains the best available information about the place.\n
  93. /// Applications must link to or embed this page on any screen that shows detailed results about the place to the user.
  94. /// </summary>
  95. public string url;
  96. /// <summary>
  97. /// Number of minutes this place’s current timezone is offset from UTC.\n
  98. /// For example, for places in Sydney, Australia during daylight saving time this would be 660 (+11 hours from UTC), and for places in California outside of daylight saving time this would be -480 (-8 hours from UTC).
  99. /// </summary>
  100. public string utc_offset;
  101. /// <summary>
  102. /// Lists a simplified address for the place, including the street name, street number, and locality, but not the province/state, postal code, or country.\n
  103. /// For example, Google's Sydney, Australia office has a vicinity value of 48 Pirrama Road, Pyrmont.
  104. /// </summary>
  105. public string vicinity;
  106. /// <summary>
  107. /// Lists the authoritative website for this place, such as a business' homepage.
  108. /// </summary>
  109. public string website;
  110. public RealWorldTerrainGooglePlaceDetailsResult()
  111. {
  112. }
  113. /// <summary>
  114. /// Constructor of RealWorldTerrainGooglePlaceDetailsResult.
  115. /// </summary>
  116. /// <param name="node">Place node from response.</param>
  117. public RealWorldTerrainGooglePlaceDetailsResult(RealWorldTerrainXML node)
  118. {
  119. this.node = node;
  120. formatted_address = node.Get("formatted_address");
  121. formatted_phone_number = node.Get("formatted_phone_number");
  122. RealWorldTerrainXML locationNode = node.Find("geometry/location");
  123. if (!locationNode.isNull) location = new Vector2(locationNode.Get<float>("lng"), locationNode.Get<float>("lat"));
  124. icon = node.Get("icon");
  125. id = node.Get("id");
  126. international_phone_number = node.Get("international_phone_number");
  127. name = node.Get("name");
  128. RealWorldTerrainXMLList photosList = node.FindAll("photo");
  129. photos = new RealWorldTerrainPlacesResult.Photo[photosList.count];
  130. for (int i = 0; i < photosList.count; i++) photos[i] = new RealWorldTerrainPlacesResult.Photo(photosList[i]);
  131. place_id = node.Get<string>("place_id");
  132. price_level = node.Get("price_level", -1);
  133. rating = node.Get<float>("rating");
  134. reference = node.Get("reference");
  135. RealWorldTerrainXMLList typeNode = node.FindAll("type");
  136. types = new string[typeNode.count];
  137. for (int i = 0; i < typeNode.count; i++) types[i] = typeNode[i].Value();
  138. url = node.Get("url");
  139. utc_offset = node.Get("utc_offset");
  140. vicinity = node.Get("vicinity");
  141. website = node.Get("website");
  142. }
  143. }
  144. }