If you’re really willing to work hard, the worst thing you can do in life is to be late.

preface

For a person who has never engaged in GIS development, it is really difficult to start at the beginning, searching various resources on the Internet, and finally…

I found the GeoServer, the source of the map. I found OpeStreetMap (OSM for Open Map in Chinese), an online map collaboration project whose goal is to create a world map that is free of content and can be edited by anyone.

How to store map data? Well, PostgreSQL with PostGIS plugin… The whole thing went down, and it was a success.

So let’s talk a little bit about how we do this step by step

The body of the

Download and install PostgreSQL and PostGIS

I found an article on the Internet. It is very easy to download and install it. Attached are two links:

Install PostgreSQL:https://www.runoob.com/postgresql/windows-install-postgresql.html

Install PostGIS:https://blog.csdn.net/antma/article/details/83580859

There are more Casts(converters) and Extensions(Extensions) under the Schemas than in the default library. It should be used mainly for space-related processing:

Download oSM2PGSQL

Download address: customdebug.com/osm/osm2pgs…

After downloading and decompressing, you also need to prepare a file: default.style

Github.com/openstreetm…

Note: Create a new TXT file, copy the code in the above link, rename it -> default.style-> place the file in... \ osm2pgSQL \x64 folder

3. Download OSM data

Osm data download: www.openstreetmap.org/#map=12/31….

You can manually select a region to download OSM data

4. Modify the PostgreSQL configuration

Modify pg_hba.conf (Path:… \ PostgreSQL \ \ data of 10)

Example Change md5 to trust

5. Import OSM data to PostgreSQL

1. Create a database OSM

2, Add postGIS object and function definition to database OSM (postgis.sql)

3, Load EPSG coordinate system definition (spatial_ref_sys.sql)

4. Import OSM data

Put the downloaded map. osM map data into… \ oSM2pgSQL \x64 folder, and open the command window in this location, (OSM is the new database, this command will download the map data into the database)

Import successful:

5, preview

After the import is successful, open pgAdmin and you can see 4 more tables:

Install GeoServer and bind data

A, download

Download address: geoserver.org/release/sta…

Platform Independent Binary: the Binary version can be decompressed to use

Second, the installation

Directly decompress, as shown below:

Run startup.bat in the bin folder (startup.sh in Linux).

After successful operation, the window cannot be closed, this is the service:

Open http://localhost:8080/geoserver/web/ as the chart, the installation is successful:

Log in to the upper right corner with the user name admin and password geoserver

Bind data publishing service

1. Add a workspace

Select “Workspace” -> “Add New Workspace” :

Enter the workspace name and namespace:

2. Add new data stores

To create a new data source, select PostGIS – PostGIS Database:

Enter the basic information about the data source, select the newly created workspace, set connection parameters to the PostgreSQL connection information, and set Database to the database where OSM data is imported in the previous section:

3. Create a new layer

After the data source is saved, it will automatically enter the new layer. Here are the layer data that can be published in this database:

Click Publish to go to edit layer:

Click “Calculate from Data” to automatically calculate borders from the layer:

After saving, go to Layer > Add New Resource:

Use the same layer as above to publish all four layers. I have published them successfully:

4. Add layer groups

Add the four layers above:

After adding the layer, click “Born on boundary” to automatically generate boundary coordinates:

Note: Layers are loaded in order from the first layer to the last, with the first layer at the bottom.

5, preview

Open “Layer Preview” – “OpenLayers” :

Success:

Conclusion:

These just download the map of the point, line, surface and other data stored in the database, the back also need to map style rendering, and secondary development… There is still a long way to go. Come on!