-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Updated to 0.0.2 with some fixes to the gem, included library and add…
…itional support for OSM model exploration. Requires the 0.3-SNAPSHOT of neo4j-spatial from 13th January 2010 (included in this gem as binary).
- Loading branch information
Craig Taverner
committed
Jan 12, 2011
1 parent
a4f2025
commit 9deab48
Showing
6 changed files
with
121 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
#!/usr/bin/env jruby | ||
|
||
# useful if being run inside a source code checkout | ||
$: << 'lib' | ||
$: << '../lib' | ||
|
||
require 'rubygems' | ||
require 'neo4j/spatial' | ||
|
||
require 'neo4j/spatial/cmd' | ||
|
||
$args = Neo4j::Spatial::Cmd.args | ||
|
||
if $list === 'layers' | ||
layers = Neo4j::Spatial::Layer.list | ||
puts "Have #{layers.length} existing layers in the database:" | ||
layers.each {|l| puts "\t#{l} (#{l.type_name})"} | ||
puts | ||
exit 0 | ||
end | ||
|
||
if $help || $args.length < 1 | ||
puts <<-eos | ||
usage: ./osm_random_trace.rb <-D storage_path> <-E dir> <-M #> <-l> <-h> layer <layers> | ||
-D Use specified database location | ||
-E Use specified export directory path (default '.') | ||
-M Number of points to include in trace (default 1000) | ||
-l List existing database layers | ||
-h Display this help and exit | ||
The layer should be a pre-existing OSM layer in the database created with OSM import. | ||
Each layer specified will have a random point selected, and then all trace a route | ||
from that point through the graph of connected ways. The entire route is then output | ||
as an SHP and PNG export. | ||
eos | ||
exit | ||
end | ||
|
||
$shp_exporter = Neo4j::Spatial::ShapefileExporter.new :dir => $export | ||
$png_exporter = Neo4j::Spatial::ImageExporter.new :dir => $export | ||
|
||
puts "Finding random routes from #{$args.length} layers" | ||
|
||
$args.each do |layer| | ||
l = Neo4j::Spatial::Layer.find layer | ||
if l.type_name === 'osm' | ||
osm = l.dataset | ||
puts "Have dataset: #{osm}" | ||
osm.ways[0..1].each do |w| | ||
puts "Have way: #{w}" | ||
puts "Have way points: #{w.points}" | ||
end | ||
#puts "Exporting #{l} (#{l.type_name}) - #{l.index.layer_bounding_box}" | ||
#$exporter.export l.name | ||
else | ||
puts "Layer #{l} does not appear to be an OSM layer" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
module Neo4j | ||
module Spatial | ||
VERSION = "0.0.1" | ||
VERSION = "0.0.2" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters