1 | 7 | simandl | #!/bin/bash |
2 | | | #<!-- Copyright (C) 2008 Petr Simandl www.simandl.cz --> |
3 | | | #<!-- This file is part of CZFGmap. --> |
4 | | | #<!-- --> |
5 | | | #<!-- CZFGmap is free software: you can redistribute it and/or modify --> |
6 | | | #<!-- it under the terms of the GNU General Public License as published by --> |
7 | | | #<!-- the Free Software Foundation, either version 3 of the License, or --> |
8 | | | #<!-- (at your option) any later version. --> |
9 | | | #<!-- --> |
10 | | | #<!-- CZFGmap is distributed in the hope that it will be useful, --> |
11 | | | #<!-- but WITHOUT ANY WARRANTY; without even the implied warranty of --> |
12 | | | #<!-- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the --> |
13 | | | #<!-- GNU General Public License for more details. --> |
14 | | | #<!-- --> |
15 | | | #<!-- You should have received a copy of the GNU General Public License --> |
16 | | | #<!-- along with CZFGmap. If not, see <http://www.gnu.org/licenses/>. --> |
17 | | | |
18 | | | datum=`date '+%Y%m%d%H%M%S'` |
19 | | | |
20 | | | outputfilen="out_node.sql" |
21 | | | outputfilel="out_line.sql" |
22 | | | |
23 | | | #stahnem nody a linky |
24 | | | if [ ! -e listnodes_${datum}.txt ] |
25 | | | then |
26 | | | # echo "neni tu "; |
27 | | | wget http://mapa.czfree.net/listnodes.php -O listnodes_${datum}.txt |
28 | | | fi |
29 | | | |
30 | | | if [ ! -e listlines_${datum}.txt ] |
31 | | | then |
32 | | | # echo "neni tu "; |
33 | | | wget http://mapa.czfree.net/listlines.php -O listlines_${datum}.txt |
34 | | | fi |
35 | | | |
36 | | | if [ -e listnodes_${datum}.txt ] |
37 | | | then |
38 | | | # echo "nodes do utf"; |
39 | | | iconv -f windows-1250 -t utf8 listnodes_${datum}.txt --output listnodesutf.txt |
40 | | | fi |
41 | | | |
42 | | | if [ -e listnodesutf.txt ] |
43 | | | then |
44 | | | # echo "delam tabulku node"; |
45 | | | cat > $outputfilen <<EOF |
46 | | | DROP TABLE node; |
47 | | | CREATE TABLE node ( |
48 | | | id int(10) unsigned NOT NULL auto_increment, |
49 | | | lat double NOT NULL default '0', |
50 | | | lon double NOT NULL default '0', |
51 | | | ownerid int(10) unsigned NOT NULL default '0', |
52 | | | networkid int(11) NOT NULL default '0', |
53 | | | type mediumint(8) unsigned NOT NULL default '0', |
54 | | | status tinyint(3) unsigned NOT NULL default '0', |
55 | | | admingroup int(11) default NULL, |
56 | | | ostype int(11) default NULL, |
57 | | | osversion int(11) default NULL, |
58 | | | name varchar(100) default NULL, |
59 | | | address varchar(120) default NULL, |
60 | | | urlphotos varchar(90) default NULL, |
61 | | | urlhomepage varchar(60) default NULL, |
62 | | | urlthread varchar(60) default NULL, |
63 | | | visibilitydesc blob, |
64 | | | changed_by int(10) unsigned default NULL, |
65 | | | changed_on datetime default NULL, |
66 | | | align int(11) default '0', |
67 | | | peoplecount smallint(5) unsigned default NULL, |
68 | | | machinecount smallint(5) unsigned default NULL, |
69 | | | peoplehide enum('0','1') NOT NULL default '0', |
70 | | | machinehide enum('0','1') NOT NULL default '0', |
71 | | | ownername varchar(100) default NULL, |
72 | | | PRIMARY KEY (id), |
73 | | | UNIQUE KEY name (name), |
74 | | | KEY lat_2 (lat), |
75 | | | KEY lat_3 (lat), |
76 | | | KEY id (id), |
77 | | | KEY lat (lat), |
78 | | | KEY lon (lon), |
79 | | | KEY ownerid (ownerid), |
80 | | | KEY Type (type) |
81 | | | ) TYPE=MyISAM PACK_KEYS=0; |
82 | | | EOF |
83 | | | |
84 | | | cat listnodesutf.txt | \ |
85 | | | sed 's/^\[//' | \ |
86 | | | sed 's/^\([0-9]*\)\]/\1/' | \ |
87 | | | sed 's/\\/\\\\/' | \ |
88 | | | sed 's/'\''/\\'\''/' | \ |
89 | | | awk -F "\t" '{print "INSERT INTO node VALUES ("$1","$2","$3",0,1,1,"$4",1,1,1,'\''"$6"'\'','\'\'','\'\'','\'\'','\'\'','\'\'',440,'\''2008-01-01 01:01:01'\'',0,NULL,NULL,'\'\'','\'\'','\''"$5"'\'');"}' | \ |
90 | | | uniq >> $outputfilen |
91 | | | |
92 | | | fi |
93 | | | |
94 | | | if [ -e listlines_${datum}.txt ] |
95 | | | then |
96 | | | # echo "delam tabulku line"; |
97 | | | cat > $outputfilel <<EOF |
98 | | | DROP TABLE line; |
99 | | | CREATE TABLE line ( |
100 | | | id1 int(10) unsigned NOT NULL default '0', |
101 | | | id2 int(10) unsigned NOT NULL default '0', |
102 | | | type mediumint(8) unsigned zerofill NOT NULL default '00000000', |
103 | | | status tinyint(1) unsigned NOT NULL default '0', |
104 | | | perm1 tinyint(1) unsigned NOT NULL default '0', |
105 | | | perm2 tinyint(1) unsigned NOT NULL default '0', |
106 | | | changed_by int(10) unsigned default NULL, |
107 | | | changed_on datetime default NULL, |
108 | | | backbone tinyint(1) unsigned NOT NULL default '0', |
109 | | | inplanning tinyint(1) unsigned NOT NULL default '0', |
110 | | | comment varchar(128) NOT NULL default '', |
111 | | | PRIMARY KEY (id1,id2), |
112 | | | KEY id1 (id1), |
113 | | | KEY id2 (id2), |
114 | | | KEY last (changed_on), |
115 | | | KEY backbone (backbone), |
116 | | | KEY inplanning (inplanning) |
117 | | | ) TYPE=MyISAM; |
118 | | | EOF |
119 | | | |
120 | | | cat listlines_${datum}.txt | \ |
121 | | | sed 's/\[\([0-9]*\)\]/\1/g' | \ |
122 | | | awk -F "\t" '{print "INSERT INTO line VALUES ("$1","$2","$3",0,40,40,88,'\''2008-01-01 01:01:01'\'',0"$4",0,'\'\'');"}' | \ |
123 | | | uniq >> $outputfilel |
124 | | | |
125 | | | fi |
126 | | | |
127 | | | |
128 | | | |
129 | | | |