Class: LayerWriter
- Inherits:
-
Object
- Object
- LayerWriter
- Defined in:
- lib/gis_scraper/layer_writer.rb
Overview
tool to write ArcGIS layer(s) to json or database output rubocop:disable Metrics/ClassLength
Constant Summary collapse
- GDAL =
/GDAL (\d+\.\d+\.\d+)/
- V1_11_4 =
Gem::Version.new('1.11.4')
- TABLES =
"SELECT table_name FROM information_schema.tables WHERE table_schema = 'public'"
- TYPES =
['Group ', 'Feature ', 'Annotation ', 'Annotation Sub'].freeze
- CONN =
%i[host port dbname user password].freeze
- GEOM_TYPES =
{ 'esriGeometryPoint' => 'POINT', 'esriGeometryMultipoint' => 'MULTIPOINT', 'esriGeometryLine' => 'LINESTRING', 'esriGeometryPolyline' => 'MULTILINESTRING', 'esriGeometryPolygon' => 'MULTIPOLYGON' }.freeze
- OGR =
'ogr2ogr -overwrite -f "PostgreSQL" PG:'
Instance Attribute Summary collapse
-
#type ⇒ Object
readonly
Returns the value of attribute type.
Instance Method Summary collapse
-
#initialize(url:, path: nil, arcrest_opts: {}) ⇒ LayerWriter
constructor
A new instance of LayerWriter.
- #output_json ⇒ Object
- #output_to_db ⇒ Object
Constructor Details
#initialize(url:, path: nil, arcrest_opts: {}) ⇒ LayerWriter
Returns a new instance of LayerWriter.
24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/gis_scraper/layer_writer.rb', line 24 def initialize(url:, path: nil, arcrest_opts: {}) @url = url @output_path = output_path(path) || config_path @arcrest_opts = arcrest_opts @conn = conn @id = id @service_url = service_url @layer = layer @page_json = @layer.json @type = layer_type @name = name end |
Instance Attribute Details
#type ⇒ Object (readonly)
Returns the value of attribute type.
10 11 12 |
# File 'lib/gis_scraper/layer_writer.rb', line 10 def type @type end |
Instance Method Details
#output_json ⇒ Object
37 38 39 |
# File 'lib/gis_scraper/layer_writer.rb', line 37 def output_json output(:json) end |
#output_to_db ⇒ Object
41 42 43 44 45 46 |
# File 'lib/gis_scraper/layer_writer.rb', line 41 def output_to_db raise 'ogr2ogr executable missing, is GDAL installed and in your PATH?' unless (v_string = ogr2ogr?) raise 'ogr2ogr version must be > 1.11.4' unless Gem::Version.new(v_string.match(GDAL)[1]) > V1_11_4 output(:db) end |