Class: GPX::GeoJSON
- Inherits:
-
Object
- Object
- GPX::GeoJSON
- Defined in:
- lib/gpx/geo_json.rb
Overview
Class to parse GeoJSON LineStrings, MultiLineStrings, Points, and MultiPoint geometric objects to GPX format. For the full specification of GeoJSON, see:
http://geojson.org/geojson-spec.html
Note that GeoJSON coordinates are specified in lon/lat format, instead of the more traditional lat/lon format.
Constant Summary collapse
- FEATURE =
'Feature'
- LINESTRING =
'LineString'
- MULTILINESTRING =
'MultiLineString'
- POINT =
'Point'
- MULTIPOINT =
'MultiPoint'
Class Method Summary collapse
-
.convert_to_gpx(opts = {}) ⇒ Object
Conversion can be initiated by either specifying a file, file name, or by passing in GeoJSON data as a string.
Class Method Details
.convert_to_gpx(opts = {}) ⇒ Object
Conversion can be initiated by either specifying a file, file name, or by passing in GeoJSON data as a string. Examples:
GPX::GeoJSON.convert_to_gpx(geojson_file: 'mygeojsonfile.json')
or
file = File.new('mygeojsonfile.json', 'r')
GPX::GeoJSON.convert_to_gpx(geojson_file: file)
or
data = JSON.generate(my_geojson_hash)
GPX::GeoJSON.convert_to_gpx(geojson_data: data)
Returns a GPX::GPX_File object populated with the converted data.
34 35 36 37 38 39 40 |
# File 'lib/gpx/geo_json.rb', line 34 def convert_to_gpx(opts = {}) geojson = geojson_data_from(opts) gpx_file = GPX::GPXFile.new add_tracks_to(gpx_file, geojson, opts) add_waypoints_to(gpx_file, geojson, opts) gpx_file end |