class SimpleMappr
Constants
- API_URL
- LAYERS
- OUTPUTS
- PROJECTIONS
- SHAPES
- VERSION
Public Class Methods
api_url()
click to toggle source
# File lib/simple-mappr/constants.rb, line 64 def self.api_url API_URL end
layers()
click to toggle source
# File lib/simple-mappr/constants.rb, line 76 def self.layers LAYERS end
new()
click to toggle source
# File lib/simple-mappr.rb, line 9 def initialize @parameters = {} end
outputs()
click to toggle source
# File lib/simple-mappr/constants.rb, line 80 def self.outputs OUTPUTS end
projections()
click to toggle source
# File lib/simple-mappr/constants.rb, line 72 def self.projections PROJECTIONS end
shapes()
click to toggle source
# File lib/simple-mappr/constants.rb, line 68 def self.shapes SHAPES end
version()
click to toggle source
# File lib/simple-mappr/version.rb, line 4 def self.version VERSION end
Public Instance Methods
alive?()
click to toggle source
Check if the RESTful API is alive and well
# File lib/simple-mappr.rb, line 23 def alive? response = Transporter.ping response[:status] == "ok" end
bbox()
click to toggle source
# File lib/simple-mappr.rb, line 78 def bbox @parameters[:bbox] || nil end
bbox=(bbox)
click to toggle source
color()
click to toggle source
# File lib/simple-mappr.rb, line 94 def color @parameters[:color] || nil end
color=(color)
click to toggle source
create()
click to toggle source
Send the SimpleMappr
object to the RESTful API and receive a Hash in return containing a URL to the image and its expected expiry
Example Output¶ ↑
{ imageURL: "http://img.simplemappr.net/579273e6_1dd1_2.png", expiry: "2016-07-22T21:28:38-04:00", bad_points: [], bad_drawings: [] }
# File lib/simple-mappr.rb, line 42 def create Transporter.send_data @parameters end
download(file_title = nil)
click to toggle source
Send the SimpleMappr
object to the RESTful API and a file title without extension and download the resulting image Returns the file path for the downloaded file
Example¶ ↑
instance.download("/tmp/my_map")
Returns
/tmp/my_map.png
# File lib/simple-mappr.rb, line 57 def download(file_title = nil) if !file_title raise InvalidParameterValue, "File path is required" end file_name = [file_title,output].join(".") IO.copy_stream(open(create[:imageURL]), file_name) file_name end
file_path()
click to toggle source
# File lib/simple-mappr.rb, line 110 def file_path @parameters[:file].path rescue nil end
file_path=(file_path)
click to toggle source
graticules()
click to toggle source
# File lib/simple-mappr.rb, line 126 def graticules @parameters[:graticules] || nil end
graticules=(graticules)
click to toggle source
height()
click to toggle source
# File lib/simple-mappr.rb, line 143 def height @parameters[:height] || nil end
height=(height)
click to toggle source
hide_gridlabel()
click to toggle source
# File lib/simple-mappr.rb, line 159 def hide_gridlabel @parameters[:hide_gridlabel] || nil end
hide_gridlabel=(label)
click to toggle source
layers()
click to toggle source
# File lib/simple-mappr.rb, line 177 def layers @parameters[:layers] || nil end
layers=(layers)
click to toggle source
Specify the layers to include in the image Expressed as a comma-separated String without spaces See SimpleMappr.layers
Example¶ ↑
instance.layers = 'oceans,lakes,rivers'
# File lib/simple-mappr.rb, line 172 def layers=(layers) Validator.validate_layers(layers) @parameters[:layers] = layers end
legend()
click to toggle source
# File lib/simple-mappr.rb, line 194 def legend @parameters[:legend] || nil end
legend=(legend)
click to toggle source
origin()
click to toggle source
# File lib/simple-mappr.rb, line 210 def origin @parameters[:origin] || nil end
origin=(origin)
click to toggle source
outlinecolor()
click to toggle source
# File lib/simple-mappr.rb, line 226 def outlinecolor @parameters[:outlinecolor] || nil end
outlinecolor=(outlinecolor)
click to toggle source
output()
click to toggle source
# File lib/simple-mappr.rb, line 243 def output @parameters[:output] || "png" end
output=(output)
click to toggle source
params()
click to toggle source
View the built parameters
# File lib/simple-mappr.rb, line 16 def params @parameters end
points()
click to toggle source
# File lib/simple-mappr.rb, line 261 def points @parameters[:points] || nil end
points=(points)
click to toggle source
An array of geographic coordinates, each as latitude,longitude Group coordinates in array elements, each of which can also be separated by linebreaks, n
Example¶ ↑
instance.points = ["45,-120\n45.4,-110","52,-120"]
# File lib/simple-mappr.rb, line 256 def points=(points) Validator.validate_points(points) @parameters[:points] = points end
projection()
click to toggle source
# File lib/simple-mappr.rb, line 278 def projection @parameters[:projection] || nil end
projection=(projection)
click to toggle source
scalebar()
click to toggle source
# File lib/simple-mappr.rb, line 294 def scalebar @parameters[:scalebar] || nil end
scalebar=(scalebar)
click to toggle source
shade()
click to toggle source
# File lib/simple-mappr.rb, line 311 def shade @parameters[:shade] || nil end
shade=(shade)
click to toggle source
shadow()
click to toggle source
# File lib/simple-mappr.rb, line 362 def shadow @parameters[:shadow] || nil end
shadow=(shadow)
click to toggle source
shape()
click to toggle source
# File lib/simple-mappr.rb, line 328 def shape @parameters[:shape] || nil end
shape=(shape)
click to toggle source
size()
click to toggle source
# File lib/simple-mappr.rb, line 345 def size @parameters[:size] || nil end
size=(size)
click to toggle source
spacing()
click to toggle source
# File lib/simple-mappr.rb, line 379 def spacing @parameters[:spacing] || nil end
spacing=(spacing)
click to toggle source
url()
click to toggle source
# File lib/simple-mappr.rb, line 396 def url @parameters[:url] || nil end
url=(url)
click to toggle source
watermark()
click to toggle source
# File lib/simple-mappr.rb, line 413 def watermark @parameters[:watermark] || nil end
watermark=(mark)
click to toggle source
width()
click to toggle source
# File lib/simple-mappr.rb, line 430 def width @parameters[:width] || nil end
width=(width)
click to toggle source
wkt()
click to toggle source
# File lib/simple-mappr.rb, line 447 def wkt @parameters[:wkt] || nil end
wkt=(wkt)
click to toggle source
Include wkt regions as an Array of Hashes Specify color, title, data, and border as keys for each element
Example¶ ↑
instance.wkt = [{ color: "200,200,200", title: "My Regions", data: "POLYGON((-70 63,-70 48,-106 48,-106 63,-70 63))" }]
# File lib/simple-mappr.rb, line 442 def wkt=(wkt) Validator.validate_wkt(wkt) @parameters[:wkt] = wkt end
zoom()
click to toggle source
# File lib/simple-mappr.rb, line 464 def zoom @parameters[:zoom] || nil end