Browse Source

merge

master
Markus Bergholz 12 months ago
parent
commit
18c60b9abe
  1. 47
      README.md

47
README.md

@ -3,23 +3,28 @@
The support officially has been dropped for MySQL/Mariadb.
However, it is still possible using OSM 0.6 API.
Tested with MariaDB 10.3.22 and 10.4.12 using Osmosis Version 0.47.4
Tested with MariaDB 10.3.22 and 10.4.12 using Osmosis Version 0.47.4 and 0.48.0
# History
> https://github.com/oschrenk/osmosis-mysql
> I found an (the?) old mysql schema on [Brett Henderson](https://github.com/brettch)'s Homepage and started from there. If you are interested in the changes I made, take a look into the [problems](PROBLEMS.md) and the history of git repository.
# Import osm.bz2 into mariadb
Take the schema here from the repository.
mysql -u osm -posm -h localhost < mariadb-osm.sql
mysql -u osm -posm -h localhost < mariadb-osm.sql
osmosis accept only `.gz`
bzip2 -dc planet-200504.osm.bz2 | gzip > planet-200504.osm.gz
89G May 7 20:31 planet-200504.osm.bz2
118G May 11 23:04 planet-200504.osm.gz
Read data and populate database
./bin/osmosis --read-xml file="andorra-latest.osm.bz2" --write-apidb-0.6 host="127.0.0.1" dbType="mysql" database="osm" user="osm" password="osm" validateSchemaVersion=no
./bin/osmosis --read-xml file="andorra-latest.osm.gz" --write-apidb-0.6 host="127.0.0.1" dbType="mysql" database="osm" user="osm" password="osm" validateSchemaVersion=no
# Import POI from pbf
@ -37,23 +42,23 @@ Read data and populate database
--write-apidb-0.6 host="127.0.0.1" dbType="mysql" database="osm" user="osm" password="osm" validateSchemaVersion=no
```
## Usage ##
## Usage
Return all main streets in a bounding box
select w.`id`, w.sequence_id, latitude, longitude, t1.v as name, t2.v as type
from current_way_nodes w, current_nodes n, current_way_tags t1, current_way_tags t2
where w.`node_id` = n.`id`
and w.`id` = t1.`way_id`
and w.`id` = t2.`way_id`
and t1.k = 'name'
and t1.v <> ''
and t2.k = 'highway'
and t2.v in ('primary', 'secondary', 'tertiary', 'motorway', 'residential', 'road', 'track', 'trunk')
and n.latitude > 53 * 10000000
and n.latitude < 54 * 10000000
and n.longitude > 8 * 10000000
and n.longitude < 9 * 10000000
order by w.`id` asc, w.sequence_id asc;
OSM uses Fixed Precision Integer for the geographical location. Instead of persisting `53,0749415` as a floating point number in the database, it will be persisted as `530749415`. The precision of the floating point number is [defined](http://wiki.openstreetmap.org/wiki/Node#Structure) as `7` decimal places, so you have to multiply or divide with `10^7`.
select w.`id`, w.sequence_id, latitude, longitude, t1.v as name, t2.v as type
from current_way_nodes w, current_nodes n, current_way_tags t1, current_way_tags t2
where w.`node_id` = n.`id`
and w.`id` = t1.`way_id`
and w.`id` = t2.`way_id`
and t1.k = 'name'
and t1.v <> ''
and t2.k = 'highway'
and t2.v in ('primary', 'secondary', 'tertiary', 'motorway', 'residential', 'road', 'track', 'trunk')
and n.latitude > 53 * 10000000
and n.latitude < 54 * 10000000
and n.longitude > 8 * 10000000
and n.longitude < 9 * 10000000
order by w.`id` asc, w.sequence_id asc;
OSM uses Fixed Precision Integer for the geographical location. Instead of persisting `53,0749415` as a floating point number in the database, it will be persisted as `530749415`. The precision of the floating point number is [defined](http://wiki.openstreetmap.org/wiki/Node#Structure) as `7` decimal places, so you have to multiply or divide with `10^7`.
Loading…
Cancel
Save