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

Set a bounding box in decimal degrees as minx,miny,maxx,maxy

Example

instance.bbox = "-120,45,-100,52"
# File lib/simple-mappr.rb, line 73
def bbox=(bbox)
  Validator.validate_bbox(bbox)
  @parameters[:bbox] = bbox
end
color() click to toggle source
# File lib/simple-mappr.rb, line 94
def color
  @parameters[:color] || nil
end
color=(color) click to toggle source

Set the colors in rgb corresponding to the points

Example

instance.color = ["255,0,0","0,255,0"]
# File lib/simple-mappr.rb, line 89
def color=(color)
  Validator.validate_colors(color)
  @parameters[:color] = color
end
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

Set a file path for a csv or tab-separated text file

Example

instance.file_path = "/Users/SimpleMappr/demo.txt"
# File lib/simple-mappr.rb, line 105
def file_path=(file_path)
  Validator.validate_type(file_path, 'File')
  @parameters[:file] = File.new(file_path, "r")
end
graticules() click to toggle source
# File lib/simple-mappr.rb, line 126
def graticules
  @parameters[:graticules] || nil
end
graticules=(graticules) click to toggle source

Turn on or off the graticules (grid)

Example

instance.graticules = true
# File lib/simple-mappr.rb, line 121
def graticules=(graticules)
  Validator.validate_type(graticules, 'Boolean')
  @parameters[:graticules] = graticules
end
height() click to toggle source
# File lib/simple-mappr.rb, line 143
def height
  @parameters[:height] || nil
end
height=(height) click to toggle source

Specify the height of the image in pixels Maximum value is 4500

Example

instance.height = 1_000
# File lib/simple-mappr.rb, line 138
def height=(height)
  Validator.validate_dimension(height)
  @parameters[:height] = height
end
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

Show/hide graticule labels

Example

instance.hide_gridlabel = true
# File lib/simple-mappr.rb, line 154
def hide_gridlabel=(label)
  Validator.validate_type(label, 'Boolean')
  @parameters[:hide_gridlabel] = label
end
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

Specify the legend title(s) Expressed as an array of Strings corresponding to the points

Example

instance.legend = ['My First Legend','My Second Legend']
# File lib/simple-mappr.rb, line 189
def legend=(legend)
  Validator.validate_type(legend, 'Array')
  @parameters[:legend] = legend
end
origin() click to toggle source
# File lib/simple-mappr.rb, line 210
def origin
  @parameters[:origin] || nil
end
origin=(origin) click to toggle source

Specify the origin of natural longitude

Example

instance.origin = -100
# File lib/simple-mappr.rb, line 205
def origin=(origin)
  Validator.validate_origin(origin)
  @parameters[:origin] = origin
end
outlinecolor() click to toggle source
# File lib/simple-mappr.rb, line 226
def outlinecolor
  @parameters[:outlinecolor] || nil
end
outlinecolor=(outlinecolor) click to toggle source

Specify the color in rgb for the outline around all points

Example

instance.outlinecolor = "10,10,10"
# File lib/simple-mappr.rb, line 221
def outlinecolor=(outlinecolor)
  Validator.validate_color(outlinecolor)
  @parameters[:outlinecolor] = outlinecolor
end
output() click to toggle source
# File lib/simple-mappr.rb, line 243
def output
  @parameters[:output] || "png"
end
output=(output) click to toggle source

Specify the output file format Options are svg, png, or jpg

Example

instance.output = "png"
# File lib/simple-mappr.rb, line 238
def output=(output)
  Validator.validate_output(output)
  @parameters[:output] = output
end
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

Specify the projection See simple-mappr/constants.rb

Example

instance.projection = "epsg:4326"
# File lib/simple-mappr.rb, line 273
def projection=(projection)
  Validator.validate_projection(projection)
  @parameters[:projection] = projection
end
scalebar() click to toggle source
# File lib/simple-mappr.rb, line 294
def scalebar
  @parameters[:scalebar] || nil
end
scalebar=(scalebar) click to toggle source

Include an embedded scalebar

Example

instance.scalebar = true
# File lib/simple-mappr.rb, line 289
def scalebar=(scalebar)
  Validator.validate_type(scalebar, 'Boolean')
  @parameters[:scalebar] = scalebar
end
shade() click to toggle source
# File lib/simple-mappr.rb, line 311
def shade
  @parameters[:shade] || nil
end
shade=(shade) click to toggle source

Include shaded regions as a Hash Specify color, title, and places as keys

Example

instance.shade = { color: "200,200,200", title: "My Regions", places: "Canada,US[WY|WA]"}
# File lib/simple-mappr.rb, line 306
def shade=(shade)
  Validator.validate_shade(shade)
  @parameters[:shade] = shade
end
shadow() click to toggle source
# File lib/simple-mappr.rb, line 362
def shadow
  @parameters[:shadow] || nil
end
shadow=(shadow) click to toggle source

Specify if shadow should be drawn under corresponding points Must be boolean

Example

instance.shadow = [true,false]
# File lib/simple-mappr.rb, line 357
def shadow=(shadow)
  Validator.validate_shadows(shadow)
  @parameters[:shadow] = shadow
end
shape() click to toggle source
# File lib/simple-mappr.rb, line 328
def shape
  @parameters[:shape] || nil
end
shape=(shape) click to toggle source

Describe the shape to use corresponding to the points See simple-mappr/constants.rb

Example

instance.shape = ['circle','square']
# File lib/simple-mappr.rb, line 323
def shape=(shape)
  Validator.validate_shapes(shape)
  @parameters[:shape] = shape
end
size() click to toggle source
# File lib/simple-mappr.rb, line 345
def size
  @parameters[:size] || nil
end
size=(size) click to toggle source

Specify the size of the corresponding points Options are Integer less than or equal to 14

Example

instance.size = [8,14]
# File lib/simple-mappr.rb, line 340
def size=(size)
  Validator.validate_sizes(size)
  @parameters[:size] = size
end
spacing() click to toggle source
# File lib/simple-mappr.rb, line 379
def spacing
  @parameters[:spacing] || nil
end
spacing=(spacing) click to toggle source

Specify the spacing between graticule (grid) lines in degrees Must be an Integer less than or equal to 10

Example

instance.spacing = 5
# File lib/simple-mappr.rb, line 374
def spacing=(spacing)
  Validator.validate_spacing(spacing)
  @parameters[:spacing] = spacing
end
url() click to toggle source
# File lib/simple-mappr.rb, line 396
def url
  @parameters[:url] || nil
end
url=(url) click to toggle source

Specify a remote URL Source must be a csv, a tab-delimited file, or a GeoRSS

Example

instance.url = "http://www.simplemappr.net/public/files/demo.csv"
# File lib/simple-mappr.rb, line 391
def url=(url)
  Validator.validate_url(url)
  @parameters[:url] = url
end
watermark() click to toggle source
# File lib/simple-mappr.rb, line 413
def watermark
  @parameters[:watermark] || nil
end
watermark=(mark) click to toggle source

Specify if watermark is shown Must be boolean

Example

instance.watermark = [true,false]
# File lib/simple-mappr.rb, line 408
def watermark=(mark)
  Validator.validate_watermark(mark)
  @parameters[:watermark] = mark
end
width() click to toggle source
# File lib/simple-mappr.rb, line 430
def width
  @parameters[:width] || nil
end
width=(width) click to toggle source

Specify the width of the output in pixels Must be less than or eqaual to 4500

Example

instance.width = 1_000
# File lib/simple-mappr.rb, line 425
def width=(width)
  Validator.validate_dimension(width)
  @parameters[:width] = width
end
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
zoom=(zoom) click to toggle source

Specify a zoom level, centred on the geographic center of all points Must be less than or eqaual to 10

Example

instance.zoom = 3
# File lib/simple-mappr.rb, line 459
def zoom=(zoom)
  Validator.validate_zoom(zoom)
  @parameters[:zoom] = zoom
end