This blog is about how to do web mapping with local database and server.

Tools:

  • Java
  • Apache Tomcat
  • PostgreSQL
  • GeoServer

Install Java

Install jdk-10.0.1_windows-x64_bin.exe and jre-8u171-windows-i586.exe

Set system environment:

Variable Value
JAVA_HOME C:\Program Files (x86)\Java\jdk1.8.0_171
JAVA_BIN %JAVA_HOME%\bin

Check Java in cmd:

1
2
3
4
5
java -version

java version "1.8.0_171"
Java(TM) SE Runtime Environment (build 1.8.0_171-b11)
Java HotSpot(TM) Client VM (build 25.171-b11, mixed mode)

Deploy Apache Tomcat

Unzip apache-tomcat-9.0.8-windows-x64.zip

Set system environment:

Variable Value
CATALINA_BASE C:\apache-tomcat-9.0.8
CATALINA_BIN C:\apache-tomcat-9.0.8\bin
CATALINA_HOME C:\apache-tomcat-9.0.8

Add users in ‪C:\apache-tomcat-9.0.8\conf\tomcat-users.xml:

1
2
3
<role rolename="manager-gui"/> 
<role rolename="admin-gui"/>
<user username="tomcat" password="tomcat" roles="manager-gui"/>

Chnage Tomcat port in C:\apache-tomcat-9.0.8\conf\server.xml if 8080 is occupied:

1
2
3
<Connector port="8090" protocol="HTTP/1.1"
connectionTimeout="20000"
redirectPort="8443" />

Increase Tomcat file size in C:\apache-tomcat-9.0.8\webapps\manager\WEB-INF\web.xml:

1
2
<max-file-size>252428800</max-file-size>
<max-request-size>252428800</max-request-size>

Start server C:\apache-tomcat-9.0.8\bin\service.bat

Close your firewall.

Open localhost:8090 in a browser.

If Tomcat flashback, check Tomcat in debug mode:

1
2
cd to\your\tomcat\bin
startup.bat debug

Publish local geodata as WMS

Install PostgreSQL(Database) and PostGIS(a spatial database extender), and GeoServer.

Input Geodata (e.g. shape file) to PostgreSQL by PostGIS.

PostgreSQL web UI

Login GeoServer http://localhost:8080/geoserver, click Stores add data from database, click Layers to publish a layer as WMS, click Layer Groups to organize Layers. Finally, click Layer preview , open layers afrom OpenLayers to preview.

GeoServer Layer Preview

Publish website

Finish your front-end codes (HTML, CSS, JS), include the WMS in your JS codes. Open a command window on your website folder:

1
jar -cvf webmapping.war *

Copy .war to Tomcat webapps folder C:\apache-tomcat-9.0.8\webapps. Start Tomcat server, login Tomcat with manager account. Click Manager App, then upload the .war file in the WAR file to deploy part and click deploy.

Tomcat Web Application Manager

If everything works, click webmapping to open the web application.

Web App

Reference

YouTube | Web mapping: PostGIS + Geoserver + QGis + Leaflet
stackoverflow | The connection was reset deploying geoserver.war in ubuntu
stackoverflow | Not able to deploy geoserver.war through apache tomcat