Module: MediaWiktory::Wikipedia::Modules::Geosearch

Defined in:
lib/mediawiktory/wikipedia/modules/geosearch.rb

Overview

Returns pages having coordinates that are located in a certain area.

The "submodule" (MediaWiki API term) is included in action after setting some param, providing additional tweaking for this param. Example (for Actions::Query and its submodules):

api.query             # returns Actions::Query
   .prop(:revisions)  # adds prop=revisions to action URL, and includes Modules::Revisions into action
   .limit(10)         # method of Modules::Revisions, adds rvlimit=10 to URL

All submodule's parameters are documented as its public methods, see below.

Instance Method Summary collapse

Instance Method Details

#bbox(value) ⇒ self

Bounding box to search in: pipe (|) separated coordinates of top left and bottom right corners.

Parameters:

  • value (String)

Returns:

  • (self)


41
42
43
# File 'lib/mediawiktory/wikipedia/modules/geosearch.rb', line 41

def bbox(value)
  merge(gsbbox: value.to_s)
end

#coord(value) ⇒ self

Coordinate around which to search.

Parameters:

  • value (String)

Returns:

  • (self)


25
26
27
# File 'lib/mediawiktory/wikipedia/modules/geosearch.rb', line 25

def coord(value)
  merge(gscoord: value.to_s)
end

#debugself

Whether debug information should be returned.

Returns:

  • (self)


124
125
126
# File 'lib/mediawiktory/wikipedia/modules/geosearch.rb', line 124

def debug()
  merge(gsdebug: 'true')
end

#globe(value) ⇒ self

Globe to search on (by default "earth").

Parameters:

  • value (String)

    One of "earth".

Returns:

  • (self)


73
74
75
# File 'lib/mediawiktory/wikipedia/modules/geosearch.rb', line 73

def globe(value)
  _globe(value) or fail ArgumentError, "Unknown value for globe: #{value}"
end

#limit(value) ⇒ self

Maximum number of pages to return.

Parameters:

  • value (Integer, "max")

Returns:

  • (self)


65
66
67
# File 'lib/mediawiktory/wikipedia/modules/geosearch.rb', line 65

def limit(value)
  merge(gslimit: value.to_s)
end

#maxdim(value) ⇒ self

Restrict search to objects no larger than this, in meters.

Parameters:

  • value (Integer)

Returns:

  • (self)


57
58
59
# File 'lib/mediawiktory/wikipedia/modules/geosearch.rb', line 57

def maxdim(value)
  merge(gsmaxdim: value.to_s)
end

#namespace(*values) ⇒ self

Namespaces to search.

Parameters:

  • values (Array<String>)

    Allowed values: "0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "100", "101", "108", "109", "118", "119", "446", "447", "710", "711", "828", "829", "2300", "2301", "2302", "2303".

Returns:

  • (self)


86
87
88
# File 'lib/mediawiktory/wikipedia/modules/geosearch.rb', line 86

def namespace(*values)
  values.inject(self) { |res, val| res._namespace(val) or fail ArgumentError, "Unknown value for namespace: #{val}" }
end

#page(value) ⇒ self

Title of page around which to search.

Parameters:

  • value (String)

Returns:

  • (self)


33
34
35
# File 'lib/mediawiktory/wikipedia/modules/geosearch.rb', line 33

def page(value)
  merge(gspage: value.to_s)
end

#primary(value) ⇒ self

Whether to return only primary coordinates ("primary"), secondary ("secondary") or both ("all").

Parameters:

  • value (String)

    One of "primary", "secondary", "all".

Returns:

  • (self)


112
113
114
# File 'lib/mediawiktory/wikipedia/modules/geosearch.rb', line 112

def primary(value)
  _primary(value) or fail ArgumentError, "Unknown value for primary: #{value}"
end

#prop(*values) ⇒ self

Which additional coordinate properties to return.

Parameters:

  • values (Array<String>)

    Allowed values: "type", "name", "dim", "country", "region", "globe".

Returns:

  • (self)


99
100
101
# File 'lib/mediawiktory/wikipedia/modules/geosearch.rb', line 99

def prop(*values)
  values.inject(self) { |res, val| res._prop(val) or fail ArgumentError, "Unknown value for prop: #{val}" }
end

#radius(value) ⇒ self

Search radius in meters.

Parameters:

  • value (Integer)

Returns:

  • (self)


49
50
51
# File 'lib/mediawiktory/wikipedia/modules/geosearch.rb', line 49

def radius(value)
  merge(gsradius: value.to_s)
end