~ubuntu-branches/ubuntu/trusty/drizzle/trusty

« back to all changes in this revision

Viewing changes to tests/kewpie/randgen/conf/oqgraph/osm2oqg.pl

  • Committer: Package Import Robot
  • Author(s): Dmitrijs Ledkovs
  • Date: 2013-10-29 15:43:40 UTC
  • mfrom: (1.2.12) (2.1.19 trusty-proposed)
  • Revision ID: package-import@ubuntu.com-20131029154340-2gp39el6cv8bwf2o
Tags: 1:7.2.3-2ubuntu1
* Merge from debian, remaining changes:
  - Link against boost_system because of boost_thread.
  - Add required libs to message/include.am
  - Add upstart job and adjust init script to be upstart compatible.
  - Disable -floop-parallelize-all due to gcc-4.8/4.9 compiler ICE
    http://gcc.gnu.org/bugzilla/show_bug.cgi?id=57732

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
use strict;
2
 
use DBI;
3
 
$| = 1;
4
 
 
5
 
my $osm_dbi = 'dbi:mysql:user=root:database=osm';
6
 
my $oqg_dbi = 'dbi:mysql:host=127.0.0.1:port=9306:database=test:user=root';
7
 
 
8
 
my $osm_dbh = DBI->connect($osm_dbi, undef , undef , { RaiseError => 1});
9
 
my $oqg_dbh = DBI->connect($oqg_dbi, undef , undef , { RaiseError => 1});
10
 
 
11
 
my $ways = $osm_dbh->selectcol_arrayref("SELECT DISTINCT id FROM ways");
12
 
 
13
 
$oqg_dbh->do("CREATE TABLE IF NOT EXISTS osm (    latch   SMALLINT  UNSIGNED NULL,    origid  BIGINT    UNSIGNED NULL,    destid  BIGINT    UNSIGNED NULL,    weight  DOUBLE    NULL,    seq     BIGINT    UNSIGNED NULL,    linkid  BIGINT    UNSIGNED NULL,    KEY (latch, origid, destid) USING HASH,    KEY (latch, destid, origid) USING HASH  ) ENGINE=OQGRAPH");
14
 
 
15
 
print "$#$ways found.\n";
16
 
 
17
 
foreach my $way (@$ways) {
18
 
        my $nodes = $osm_dbh->selectcol_arrayref("SELECT node_id FROM way_nodes WHERE id = $way ORDER BY sequence_id");
19
 
#       print "$#$nodes found for way $way\n";
20
 
 
21
 
        if ($#$nodes > 1) {
22
 
                $oqg_dbh->do("
23
 
                        INSERT INTO osm ( origid, destid ) VALUES ".
24
 
                        join(', ', map { "( $nodes->[$_] , $nodes->[$_ + 1] )" } (0..($#$nodes-1)))
25
 
                );
26
 
                print "*";
27
 
        } else {
28
 
                print ".";
29
 
        }
30
 
}