コード例 #1
0
ファイル: GeoNamesClient.cs プロジェクト: chr1sk0n/NGeo
        /// <summary>
        /// Returns the children (admin divisions and populated places) for a given geonameId. The children are the
        /// administrative divisions within an other administrative division, like the counties (ADM2) in a state (ADM1)
        /// or also the countries in a continent. The leafs are populated places, other feature classes like spots,
        /// mountains etc are not included in this service. Use
        /// the <seealso cref="http://www.geonames.org/export/geonames-search.html">search service</seealso> if you need
        /// other feature classes as well. See
        /// <seealso cref="http://www.geonames.org/export/place-hierarchy.html#children">Official GeoNames children
        /// Documentation</seealso> for more information.
        /// </summary>
        /// <param name="geoNameId">The GeoName ID of the parent.</param>
        /// <param name="userName">Your user name.</param>
        /// <param name="resultStyle">Amount of detail returned by the GeoNames service.
        /// Default value is full.</param>
        /// <param name="maxRows">Maximum results returned by the service.
        /// Default value is 200.</param>
        /// <returns>The children (admin divisions and populated places) for a given geonameId.</returns>
        public ReadOnlyCollection <Toponym> Children(int geoNameId, string userName,
                                                     ResultStyle resultStyle = ResultStyle.Medium, int maxRows = 200)
        {
            var response = ChannelChildren(geoNameId, userName, resultStyle, maxRows);
            var results  = response.Items;

            return(results != null ? new ReadOnlyCollection <Toponym>(results) : null);
        }
コード例 #2
0
ファイル: GeoNamesClient.cs プロジェクト: chr1sk0n/NGeo
 private Hierarchy ChannelHierarchy(int geoNameId, string userName, ResultStyle resultStyle, int retry = 0)
 {
     try
     {
         return(Channel.Hierarchy(geoNameId, userName, resultStyle));
     }
     catch (WebException ex)
     {
         if (retry < RetryLimit && ex.Message.StartsWith(ClosedConnectionMessage, StringComparison.Ordinal))
         {
             return(ChannelHierarchy(geoNameId, userName, resultStyle, ++retry));
         }
         throw;
     }
 }
コード例 #3
0
ファイル: GeoNamesClient.cs プロジェクト: chr1sk0n/NGeo
 private Results <Toponym> ChannelChildren(int geoNameId, string userName, ResultStyle resultStyle, int maxRows, int retry = 0)
 {
     try
     {
         return(Channel.Children(geoNameId, userName, resultStyle, maxRows));
     }
     catch (WebException ex)
     {
         if (retry < RetryLimit && ex.Message.StartsWith(ClosedConnectionMessage, StringComparison.Ordinal))
         {
             return(ChannelChildren(geoNameId, userName, resultStyle, maxRows, ++retry));
         }
         throw;
     }
 }
コード例 #4
0
ファイル: GeoNamesClient.cs プロジェクト: chr1sk0n/NGeo
 private Results <Toponym> ChannelSearch(string q, string name, string nameEquals, int maxRows, int startRow,
                                         string lang, ResultStyle resultStyle, string userName, int retry = 0)
 {
     try
     {
         return(Channel.Search(q, name, nameEquals, maxRows, startRow, lang, resultStyle, userName));
     }
     catch (WebException ex)
     {
         if (retry < RetryLimit && ex.Message.StartsWith(ClosedConnectionMessage, StringComparison.Ordinal))
         {
             return(Channel.Search(q, name, nameEquals, maxRows, startRow, lang, resultStyle, userName));
         }
         throw;
     }
 }
コード例 #5
0
ファイル: GeoNamesClient.cs プロジェクト: chr1sk0n/NGeo
        /// <summary>
        /// Returns all GeoNames higher up in the hierarchy of a place name. See
        /// <seealso cref="http://www.geonames.org/export/place-hierarchy.html#hierarchy">Official GeoNames
        /// hierarchy Documentation</seealso> for more information.
        /// </summary>
        /// <param name="geoNameId">The GeoName ID of the child toponym.</param>
        /// <param name="userName">Your user name.</param>
        /// <param name="resultStyle">Amount of detail returned by the GeoNames service.
        /// Default value is full.</param>
        /// <returns>All GeoNames higher up in the hierarchy of a place name.</returns>
        public Hierarchy Hierarchy(int geoNameId, string userName, ResultStyle resultStyle = ResultStyle.Medium)
        {
            var response = ChannelHierarchy(geoNameId, userName, resultStyle);

            return(response.Items == null ? null : response);
        }
コード例 #6
0
ファイル: GeoNamesContainer.cs プロジェクト: diaAbdoul/NGeo
 public Hierarchy Hierarchy(int geoNameId, ResultStyle resultStyle = ResultStyle.Medium)
 {
     return(_client.Hierarchy(geoNameId, _userName, resultStyle));
 }
コード例 #7
0
ファイル: GeoNamesContainer.cs プロジェクト: diaAbdoul/NGeo
 public ReadOnlyCollection <Toponym> Children(int geoNameId, ResultStyle resultStyle = ResultStyle.Medium, int maxRows = 200)
 {
     return(_client.Children(geoNameId, _userName, resultStyle, maxRows));
 }
コード例 #8
0
 public Hierarchy Hierarchy(int geoNameId, ResultStyle resultStyle = ResultStyle.Medium)
 {
     return _client.Hierarchy(geoNameId, _userName, resultStyle);
 }
コード例 #9
0
 public ReadOnlyCollection<Toponym> Children(int geoNameId, ResultStyle resultStyle = ResultStyle.Medium, int maxRows = 200)
 {
     return _client.Children(geoNameId, _userName, resultStyle, maxRows);
 }