Sha256: 458282dc394f892d4c6a930cce57026e452f4c535a1755a635ab06bd574ff0d5
Contents?: true
Size: 1.54 KB
Versions: 2
Compression:
Stored size: 1.54 KB
Contents
require 'neo4j/spatial/listener' require 'neo4j/spatial/database' require 'neo4j/spatial/geometry' java_import org.neo4j.gis.spatial.Constants java_import org.neo4j.gis.spatial.SpatialDatabaseService java_import org.neo4j.gis.spatial.ShapefileImporter module Neo4j module Spatial class SHPImporter include Listener include Database def initialize(options={}) database(options) @importer = org.neo4j.gis.spatial.ShapefileImporter.new(normal_database, self, @commit) end def import(shp_path,layer_name=nil) @shp_path = shp_path layer_name ||= shp_path.split(/[\\\/]+/)[-1].gsub(/\.\w+$/,'') puts "\n=== Loading layer #{layer_name} from #{shp_path} ===" @importer.import_file @shp_path, layer_name end def to_s @shp_path.to_s end end # This class facilitates exporting datasets in the ESRI Shapefile format class SHPExporter include Database def initialize(options={}) options[:dir] ||= "target/export" database(options) @exporter = org.neo4j.gis.spatial.ShapefileExporter.new(normal_database) @exporter.setExportDir(options[:dir]) end def export(layer_name,options={}) @layer_name = layer_name options[:path] ||= layer_name+'.shp' puts "Exporting #{layer_name} to #{options[:path]}" @exporter.exportLayer(layer_name, options[:path]) end def format "ESRI Shapefile" end def to_s @layer_name || format end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
neo4j-spatial-0.0.8-java | lib/neo4j/spatial/shp.rb |
neo4j-spatial-0.0.7-java | lib/neo4j/spatial/shp.rb |