class MarkLogic::Queries::GeospatialQuery
Public Class Methods
new(name, regions, options = {})
click to toggle source
# File lib/marklogic/queries/geospatial_query.rb, line 4 def initialize(name, regions, options = {}) @name = name @regions = regions @options = options || {} @weight = @options.delete(:weight) || 1.0 end
Public Instance Methods
options()
click to toggle source
# File lib/marklogic/queries/geospatial_query.rb, line 15 def options opts = [] @options.each do |k, v| dashed_key = k.to_s.gsub(/_/, '-') case k.to_s when "coordinate_system", "units", "type", "score_function", "slope_factor" opts << %Q{"#{dashed_key}=#{v}"} when /(boundaries)_included/ opts << (v == true ? %Q{"#{$1}-included"} : %Q{"#{$1}-excluded"}) when /([a-z\-]+_excluded)/ opts << %Q{"#{dashed_key}"} when "cached" opts << (v == true ? %Q{"cached"} : %Q{"uncached"}) when "zero", "synonym" opts << %Q{"#{dashed_key}"} # else # opts << %Q{"#{v}"} end end opts end
options=(opts)
click to toggle source
# File lib/marklogic/queries/geospatial_query.rb, line 11 def options=(opts) @options = opts end
to_xqy()
click to toggle source
# File lib/marklogic/queries/geospatial_query.rb, line 38 def to_xqy regions = query_value(@regions) %Q{cts:json-property-geospatial-query("#{@name}",(#{regions}),(#{options.join(',')}),#{@weight})} end