neo4j-spatial 0.0.5-java → 0.0.6-java

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,59 @@
1
+ #!/usr/bin/env jruby
2
+
3
+ # useful if being run inside a source code checkout
4
+ $: << 'lib'
5
+ $: << '../lib'
6
+
7
+ require 'rubygems'
8
+ require 'neo4j/spatial'
9
+ require 'neo4j/spatial/cmd'
10
+
11
+ $zoom = 1.0
12
+ $args = Neo4j::Spatial::Cmd.args
13
+
14
+ if $list === 'layers'
15
+ layers = Neo4j::Spatial::Layer.list
16
+ puts "Have #{layers.length} existing layers in the database:"
17
+ layers.each {|l| puts "\t#{l} (#{l.type_name})"}
18
+ puts
19
+ exit 0
20
+ end
21
+
22
+ if $help || $args.length < 1
23
+ puts <<-eos
24
+
25
+ usage: ./export_layer.rb <-D storage_path> <-F format> <-E dir> <-Z zoom> <-W width> <-H height> <-l> <-h> layer <layers>
26
+ -D Use specified database location
27
+ -F Use specified export format (png, shp)
28
+ -E Use specified export directory path (default '.')
29
+ -Z Zoom in by specified factor (eg. 3.0)
30
+ -W Image width (default 600)
31
+ -H Image height (default 400)
32
+ -l List existing database layers first
33
+ -h Display this help and exit
34
+ The layer(s) should be pre-existing layers (including dynamic layers) in the database.
35
+ Supported formats are 'shp' for ESRI Shapefile and 'png' for images.
36
+
37
+ For example:
38
+ ./export_layer.rb -D db -E exports -F png croatia.osm highway highway-residential natural-water
39
+
40
+ This will export four previously defined layers to png format files in the 'exports' directory.
41
+
42
+ eos
43
+ exit
44
+ end
45
+
46
+ if $format.to_s.downcase === 'shp'
47
+ $exporter = Neo4j::Spatial::ShapefileExporter.new :dir => $export
48
+ else
49
+ $exporter = Neo4j::Spatial::ImageExporter.new :dir => $export, :zoom => $zoom, :width => $width, :height => $height
50
+ end
51
+
52
+ puts "Exporting #{$args.length} layers to #{$exporter.format}"
53
+
54
+ $args.each do |layer|
55
+ l = Neo4j::Spatial::Layer.find layer
56
+ puts "Exporting #{l} (#{l.type_name}) - #{l.index.layer_bounding_box}"
57
+ $exporter.export l.name
58
+ puts "Finished exporting #{l} (#{l.type_name}) of #{l.index.count} entries"
59
+ end
@@ -0,0 +1,29 @@
1
+ #!/usr/bin/env jruby
2
+
3
+ # useful if being run inside a source code checkout
4
+ $: << 'lib'
5
+ $: << '../lib'
6
+
7
+ require 'rubygems'
8
+ require 'neo4j/spatial'
9
+ require 'neo4j/spatial/cmd'
10
+ require 'fileutils'
11
+
12
+ $files = Neo4j::Spatial::Cmd.args
13
+
14
+ if $help || $files.length < 1
15
+ puts "usage: osm_import.rb <-d> <-D storage_path> file.osm"
16
+ puts "\t-d\tDelete database first"
17
+ puts "\t-D\tUse specified database location"
18
+ exit
19
+ end
20
+
21
+ if $delete
22
+ puts "Deleting previous database #{Neo4j::Config[:storage_path]}"
23
+ FileUtils.rm_rf Neo4j::Config[:storage_path]
24
+ end
25
+
26
+ $files.each do |file|
27
+ osm_importer = Neo4j::Spatial::OSMImporter.new
28
+ osm_importer.import file
29
+ end
@@ -0,0 +1,74 @@
1
+ #!/usr/bin/env jruby
2
+
3
+ # useful if being run inside a source code checkout
4
+ $: << 'lib'
5
+ $: << '../lib'
6
+
7
+ require 'rubygems'
8
+ require 'neo4j/spatial'
9
+ require 'neo4j/spatial/cmd'
10
+
11
+ $args = Neo4j::Spatial::Cmd.args
12
+
13
+ if $list === 'layers'
14
+ layers = Neo4j::Spatial::Layer.list
15
+ puts "Have #{layers.length} existing layers in the database:"
16
+ layers.each {|l| puts "\t#{l.describe}"}
17
+ puts
18
+ exit 0
19
+ end
20
+
21
+ if $exists
22
+ if $exists == true
23
+ $exists = $args.shift
24
+ end
25
+ if Neo4j::Spatial::Layer.exist?($exists)
26
+ puts "Layer '#{$exists}' exists"
27
+ exit 0
28
+ else
29
+ puts "Layer '#{$exists}' not found"
30
+ exit -1
31
+ end
32
+ end
33
+
34
+ if $help || $args.length < 2
35
+ puts <<-eos
36
+
37
+ usage: ./osm_layer.rb <-D storage_path> <-x> <-l> <-r> <-h> layer layerspec <layerspecs>
38
+ -D Use specified database location
39
+ -x Test if specified layer exists (and exit)
40
+ -r Delete specified dynamic layer on specified osm layer
41
+ -l List existing database layers
42
+ -h Display this help and exit
43
+ The layer should be a pre-existing OSM layer in the database created with OSM import.
44
+ The layerspec(s) are strings that are composed of multiple '-' or '.' separators.
45
+ Each pair in order is treated as a property-value pair to match when searching the
46
+ original layer for the new dynamic layer geometries.
47
+
48
+ For example:
49
+ ./osm_layer.rb -D db croatia.osm highway highway-residential natural-water
50
+
51
+ This will define three dynamic layers in the croation.osm dataset:
52
+ highway all ways that have a 'highway' property
53
+ highway-residential all ways that have 'highway'='residential'
54
+ natural-waterway all ways that have 'natural'='waterway'
55
+
56
+ eos
57
+ exit
58
+ end
59
+
60
+ $layer = Neo4j::Spatial::OSMLayer.new $args.shift
61
+
62
+ if $layer.empty?
63
+ puts "No such layer: #{$layer}"
64
+ end
65
+
66
+ $args.each do |layerspec|
67
+ x = layerspec.split(/[\.-]/) << nil
68
+ x = x[0...(2*(x.length/2))] # allow only even number of entries
69
+ if $delete
70
+ $layer.remove_dynamic_layer Hash[*x]
71
+ else
72
+ $layer.add_dynamic_layer Hash[*x]
73
+ end
74
+ end
@@ -1,5 +1,5 @@
1
1
  module Neo4j
2
2
  module Spatial
3
- VERSION = "0.0.5"
3
+ VERSION = "0.0.6"
4
4
  end
5
5
  end
@@ -0,0 +1,5 @@
1
+ module Neo4j
2
+ module Spatial
3
+ VERSION = "0.0.5"
4
+ end
5
+ end
@@ -22,6 +22,7 @@ EOF
22
22
 
23
23
  s.require_path = 'lib'
24
24
  s.files = Dir.glob("{bin,lib,examples}/**/*").reject{|x| x=~/(tmp|target|croatia|test-data)/} + %w(README.rdoc CHANGELOG CONTRIBUTORS Gemfile neo4j-spatial.gemspec)
25
+ s.executables = ['osm_import', 'osm_layer', 'export_layer']
25
26
  s.has_rdoc = true
26
27
  s.extra_rdoc_files = %w( README.rdoc )
27
28
  s.rdoc_options = ["--quiet", "--title", "Neo4j-Spatial.rb", "--opname", "index.html", "--line-numbers", "--main", "README.rdoc", "--inline-source"]
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: neo4j-spatial
3
3
  version: !ruby/object:Gem::Version
4
- hash: 21
4
+ hash: 19
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
8
  - 0
9
- - 5
10
- version: 0.0.5
9
+ - 6
10
+ version: 0.0.6
11
11
  platform: java
12
12
  authors:
13
13
  - Craig Taverner
@@ -58,13 +58,18 @@ description: |
58
58
  access Neo4j-Spatial features from the convenience of the Ruby scripting language.
59
59
 
60
60
  email: craig@amanzi.com
61
- executables: []
62
-
61
+ executables:
62
+ - osm_import
63
+ - osm_layer
64
+ - export_layer
63
65
  extensions: []
64
66
 
65
67
  extra_rdoc_files:
66
68
  - README.rdoc
67
69
  files:
70
+ - bin/osm_import
71
+ - bin/osm_layer
72
+ - bin/export_layer
68
73
  - lib/neo4j/spatial/osm.rb
69
74
  - lib/neo4j/spatial/database.rb
70
75
  - lib/neo4j/spatial/layer.rb
@@ -103,6 +108,7 @@ files:
103
108
  - lib/neo4j/spatial/listener.rb
104
109
  - lib/neo4j/spatial/version.rb
105
110
  - lib/neo4j/spatial/geometry.rb
111
+ - lib/neo4j/spatial/version.rb~
106
112
  - lib/neo4j/spatial.rb
107
113
  - examples/osm_import.rb
108
114
  - examples/test.rb