OpenStreetMap

OpenStreetMap is a world map that anyone can edit and use freely.

Much of the content was built from scratch by volunteers and distributed under an open license. The OpenStreetMap copyright agreement allows free and free use of our map images and map data, and the project encourages interesting new uses of the data.

OpenStreetMap: www.openstreetmap.org

Export OSM data

If we visit the OpenStreetMap homepage above, we can see that, like other map service sites, it also provides location navigation, and also directly locates the current browsing location. How can we export map data?

There is an export button in the upper left corner of the page. After we click it, we can see the interface as shown in the picture below:

Click the export button in the red box to export all map data (streets, buildings, etc.) in the default area (the area composed of two latitudes and longitudes). The extension format of the exported data file is. Osm, and the default exported file name is map.osm.

If we need to customize the exported region, we can click “Manually select different regions” to locate the location and size of the region by dragging and dropping, as shown in the picture below:

Click the Export button to get the map data for our selected area.

Note: The disadvantage of this region export method is that the data volume cannot exceed 50000 latitude and longitude points.

Install the osmosis

By osmosis, we can import data into the database. Osx system can be installed through BREW as follows:

yuqiyu@hengyu ~> brew install osmosis
Copy the code

Initialize the database table

If you want to import a database through osmosis, you need to create a database and a table in advance.

Importing a Database

yuqiyu@hengyu ~> osmosis --read-xml file="/Users/yuqiyu/Downloads/map.osm"- write - apidb - host = 0.6"127.0.0.1" dbType="mysql" database="api06_test" user="root" password="123456" validateSchemaVersion=no
Copy the code

Type on the blackboard and underline

There are a lot of things we can do based on the open road data provided by OpenStreetMap, such as taking the longitude and latitude locations of the roads and doing some unique business things like: I can clearly know which business vehicles pass on a road, establish map data of my own business, and plan work routes.