neo4j-spatial 0.0.1-java → 0.0.2-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
|
+
|
10
|
+
require 'neo4j/spatial/cmd'
|
11
|
+
|
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: ./osm_random_trace.rb <-D storage_path> <-E dir> <-M #> <-l> <-h> layer <layers>
|
26
|
+
-D Use specified database location
|
27
|
+
-E Use specified export directory path (default '.')
|
28
|
+
-M Number of points to include in trace (default 1000)
|
29
|
+
-l List existing database layers
|
30
|
+
-h Display this help and exit
|
31
|
+
The layer should be a pre-existing OSM layer in the database created with OSM import.
|
32
|
+
Each layer specified will have a random point selected, and then all trace a route
|
33
|
+
from that point through the graph of connected ways. The entire route is then output
|
34
|
+
as an SHP and PNG export.
|
35
|
+
|
36
|
+
eos
|
37
|
+
exit
|
38
|
+
end
|
39
|
+
|
40
|
+
$shp_exporter = Neo4j::Spatial::ShapefileExporter.new :dir => $export
|
41
|
+
$png_exporter = Neo4j::Spatial::ImageExporter.new :dir => $export
|
42
|
+
|
43
|
+
puts "Finding random routes from #{$args.length} layers"
|
44
|
+
|
45
|
+
$args.each do |layer|
|
46
|
+
l = Neo4j::Spatial::Layer.find layer
|
47
|
+
if l.type_name === 'osm'
|
48
|
+
osm = l.dataset
|
49
|
+
puts "Have dataset: #{osm}"
|
50
|
+
osm.ways[0..1].each do |w|
|
51
|
+
puts "Have way: #{w}"
|
52
|
+
puts "Have way points: #{w.points}"
|
53
|
+
end
|
54
|
+
#puts "Exporting #{l} (#{l.type_name}) - #{l.index.layer_bounding_box}"
|
55
|
+
#$exporter.export l.name
|
56
|
+
else
|
57
|
+
puts "Layer #{l} does not appear to be an OSM layer"
|
58
|
+
end
|
59
|
+
end
|
data/lib/neo4j/spatial/cmd.rb
CHANGED
Binary file
|
data/lib/neo4j/spatial/osm.rb
CHANGED
@@ -5,8 +5,65 @@ java_import org.neo4j.gis.spatial.Constants
|
|
5
5
|
java_import org.neo4j.gis.spatial.SpatialDatabaseService
|
6
6
|
java_import org.neo4j.gis.spatial.osm.OSMGeometryEncoder
|
7
7
|
|
8
|
+
module Java
|
9
|
+
module OrgNeo4jGisSpatialOsm
|
10
|
+
class OSMDataset
|
11
|
+
def to_s
|
12
|
+
layers.map{|l| l.name}.join(', ')
|
13
|
+
end
|
14
|
+
def way_nodes
|
15
|
+
all_way_nodes
|
16
|
+
end
|
17
|
+
def ways
|
18
|
+
#all_way_nodes.map{|w| Neo4j::Spatial::OSMWay.new w}
|
19
|
+
Neo4j::Spatial::OSMWays.new(all_way_nodes)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
8
24
|
module Neo4j
|
9
25
|
module Spatial
|
26
|
+
class OSMWay
|
27
|
+
def initialize(node)
|
28
|
+
@node = node
|
29
|
+
end
|
30
|
+
def first_point
|
31
|
+
first_point_proxy.outgoing(:NODE).first
|
32
|
+
end
|
33
|
+
def last_point
|
34
|
+
last_point_proxy.outgoing(:NODE).first
|
35
|
+
end
|
36
|
+
def first_point_proxy
|
37
|
+
@node.outgoing(:FIRST_NODE).first
|
38
|
+
end
|
39
|
+
def last_point_proxy
|
40
|
+
@node.outgoing(:LAST_NODE).first
|
41
|
+
end
|
42
|
+
def points
|
43
|
+
@node.methods.grep(/traver/).join(', ')
|
44
|
+
first_point_proxy.outgoing(:NEXT).depth(100000).map{|n| n.outgoing(:NODE).first}
|
45
|
+
end
|
46
|
+
def to_s
|
47
|
+
@node['name'] || @node.to_s
|
48
|
+
end
|
49
|
+
end
|
50
|
+
class OSMWays
|
51
|
+
attr_reader :nodes
|
52
|
+
def initialize(nodes)
|
53
|
+
@nodes = nodes
|
54
|
+
end
|
55
|
+
def each
|
56
|
+
@nodes.each{|n| yield OSMWay.new(n)}
|
57
|
+
end
|
58
|
+
def first
|
59
|
+
OSMWay.new @nodes.first
|
60
|
+
end
|
61
|
+
def [](index)
|
62
|
+
index.is_a?(Range) ?
|
63
|
+
@nodes.to_a[index].map{|n| OSMWay.new(n)} :
|
64
|
+
OSMWay.new(@nodes.to_a[index])
|
65
|
+
end
|
66
|
+
end
|
10
67
|
class OSMLayer < Layer
|
11
68
|
def initialize(layer_name,options={})
|
12
69
|
super(layer_name, options.merge({
|
@@ -26,6 +83,7 @@ module Neo4j
|
|
26
83
|
layer.add_dynamic_layer_on_way_tags(name.to_s, gtype, java.util.HashMap.new(options))
|
27
84
|
end
|
28
85
|
end
|
86
|
+
# List dynamic layers associated with this layer
|
29
87
|
def list
|
30
88
|
@layer.layer_names
|
31
89
|
end
|
data/neo4j-spatial.gemspec
CHANGED
@@ -26,6 +26,6 @@ EOF
|
|
26
26
|
s.extra_rdoc_files = %w( README.rdoc )
|
27
27
|
s.rdoc_options = ["--quiet", "--title", "Neo4j-Spatial.rb", "--opname", "index.html", "--line-numbers", "--main", "README.rdoc", "--inline-source"]
|
28
28
|
s.required_ruby_version = ">= 1.8.7"
|
29
|
-
s.add_dependency('neo4j',">= 1.0.0")
|
29
|
+
s.add_dependency('neo4j',">= 1.0.0.beta.23")
|
30
30
|
s.add_dependency('amanzi-sld',">= 0.0.1")
|
31
31
|
end
|
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:
|
4
|
+
hash: 27
|
5
5
|
prerelease: false
|
6
6
|
segments:
|
7
7
|
- 0
|
8
8
|
- 0
|
9
|
-
-
|
10
|
-
version: 0.0.
|
9
|
+
- 2
|
10
|
+
version: 0.0.2
|
11
11
|
platform: java
|
12
12
|
authors:
|
13
13
|
- Craig Taverner
|
@@ -15,7 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-01-
|
18
|
+
date: 2011-01-13 00:00:00 +01:00
|
19
19
|
default_executable:
|
20
20
|
dependencies:
|
21
21
|
- !ruby/object:Gem::Dependency
|
@@ -26,12 +26,14 @@ dependencies:
|
|
26
26
|
requirements:
|
27
27
|
- - ">="
|
28
28
|
- !ruby/object:Gem::Version
|
29
|
-
hash:
|
29
|
+
hash: 62196397
|
30
30
|
segments:
|
31
31
|
- 1
|
32
32
|
- 0
|
33
33
|
- 0
|
34
|
-
|
34
|
+
- beta
|
35
|
+
- 23
|
36
|
+
version: 1.0.0.beta.23
|
35
37
|
type: :runtime
|
36
38
|
version_requirements: *id001
|
37
39
|
- !ruby/object:Gem::Dependency
|
@@ -105,6 +107,7 @@ files:
|
|
105
107
|
- examples/map2.osm
|
106
108
|
- examples/osm_layer.rb
|
107
109
|
- examples/map.osm
|
110
|
+
- examples/osm_random_trace.rb
|
108
111
|
- README.rdoc
|
109
112
|
- CHANGELOG
|
110
113
|
- CONTRIBUTORS
|