Skip to content
Feussi edited this page Mar 16, 2021 · 6 revisions

Documentation of Shape2OhdmTool as Supplementary documentation for OHDMImportTool

Welcome to the Shape2OhdmTool!

This tool allows you to import Shapefiles into a OHDM database. The user can upload Shape data from a selectet shapeData (as table) form intermediateosm Schema (Import DB) to the ohmd schema (OHDM DB).


Import DB to OHDM DB


This software is under GPL 3.0 and can be found in the OHDM Software Repository

The Shape2OhdmTool is a further development of the OHDMImportTool . The introduction to the further development is therefore the same as in the Wiki.

Requirements

In order to run this tool, the data must first be available in the intermediateosm.

Therefore a small repetition of some system requirements to carry out the 1st step of the import process:

To let it run on your system you need following things configured/installed:

  • TomCat 9.X The TomCat server have to be installed on the user system PostgreSQL 9.6 at less

  • Environment variable for the corresponding database like PGPASSWORD, PGUSER sometimes in [C:\Program Files\PostgreSQL\9.6\pg_env.bat](C:\Program Files\PostgreSQL\9.6\pg_env.bat)

  • MAVEN

  • Postgresql DB with PostGIS.

Very Important !: Some extensions have to be installed in the ohdm database: hstore etc…

  • pgAdmin to inspect the Database on the Browser
  • Java Version 8 at less

Shapefiles which are desired to be imported need the following files:


Shapefile 
* (.shp) 
* (.shx)
* (.dbf) 

Here are some shapefiles with which the project was tested: https://github.com/OpenHistoricalMap/data

Usage as OHDM User

  1. Configure CATALINA_HOME env. Variable like:

C:> echo% CATALINA_HOME%
C:\Program Files (x86)\Apache Software Foundation\Tomcat 9.x;
  1. Download the release 1.0.0 of OhdmImportTool and load the .war file on the Tomcat Server.

  2. Restart the Tomcat Webserver and launch http://localhost:8080

  3. Here you can navigate to upload the Shapefile (some samples at: https://github.com/OpenHistoricalMap/data )

Please make sure that the zip file only contain this files: .cpg, .dbf ect…

  1. Load the file, enter your username and press open, the shapefile will be load on a browser like:

Result Import to Ipmport DB

Here the shapefile is already in the intermediateosm scheme.

If it fails, please see the paths in GenConfigs. After the first part of the upload process has been carried out, the configuration data is saved in

C:\Program Files\Apache Software Foundation\Tomcat 9.X\bin\configFiles\GenConfigs and looks like


DB_USER = postgres
DB_PASS = root
DB_NAME = ohdm
DB_HOST = localhost
SCHEME_TEMP = temp
SCHEME_TEST = test
SCHEME_CACHE = intermediateosm
DB_GEO_USER=geoserver
DB_HOST_OHDM = localhost
DB_PORT_OHDM = 5432
DB_USER_OHDM = postgres
DB_PASS_OHDM = root
DB_NAME_INTERMEDIATE =ohdm
DB_NAME_OHDM = ohdm
SCHEME_OHDM = ohdm
SCHEME_INTERMEDIATE = intermediateosm
GID=gid
GEOM=geom
COLUMNVALIDSINCEDAY=23
COLUMNVALIDSINCEMONTH=09
COLUMNVALIDSINCEYEAR=1930
COLUMNVALIDUNTILDAY=07
COLUMNVALIDUNTILMONTH=07
COLUMNVALIDUNTILYEAR=2017
VALIDSINCE=12-04-1999
VALIDUNTIL=12-04-2022
CLASSIFICATION_ID=13
JDBC_DRIVER_PATH= C:\dev\ohdm\postgresql-42.1.1.jar
OHDM_CONVERTER_PATH=C:\dev\ohdm\OHDMConverter.jar
TABLENAME=20210307214941
SHP_TO_PGSQL_FILE_PATH = C:\Program Files\PostgreSQL\9.6\bin\shp2pgsql.exe
PGSQL_FILE_PATH = C:\Program Files\PostgreSQL\9.6\bin\psql.exe

If necessary, please adjust before continue the next step.

  1. Start the import to ohdm database

If everything is set up, now it is time to push Data on the Ohdm Database:


Java -jar Shape2OhdmTool.jar "CONFIG_PATH" TABLENAME

the result should look like:


Import cmd to OHDM DB


Entering the table Name is optional, if none is specified, the entered table is considered in GenConfigs.


Usage as Developper

Clone this projects and open it with Intellij IDE:


$ git clone https://github.com/OpenHistoricalDataMap/OHDMImportTool.git

$ git clone https://github.com/OpenHistoricalDataMap/Shape2OhdmTool.git

1. Step

Configure the necessary constants in the file OHDMImportTool src/main/webapp/java/de/htwb/shpImport/ShapeImporter.java

After the first part of the upload process has been carried out, the configuration data is saved in

C:\Program Files\Apache Software Foundation\Tomcat 9.X\bin\configFiles\GenConfigs

If necessary, please adjust before the 2nd step.


Hier a sample contain of the Configfile:


DB_USER = postgres
DB_PASS = root
DB_NAME = ohdm
DB_HOST = localhost
SCHEME_TEMP = temp
SCHEME_TEST = test
SCHEME_CACHE = intermediateosm
DB_GEO_USER=geoserver
DB_HOST_OHDM = localhost
DB_PORT_OHDM = 5432
DB_USER_OHDM = postgres
DB_PASS_OHDM = root
DB_NAME_INTERMEDIATE =ohdm
DB_NAME_OHDM = ohdm
SCHEME_OHDM = ohdm
SCHEME_INTERMEDIATE = intermediateosm
GID=gid
GEOM=geom
COLUMNVALIDSINCEDAY=23
COLUMNVALIDSINCEMONTH=09
COLUMNVALIDSINCEYEAR=1930
COLUMNVALIDUNTILDAY=07
COLUMNVALIDUNTILMONTH=07
COLUMNVALIDUNTILYEAR=2017
VALIDSINCE=12-04-1999
VALIDUNTIL=12-04-2022
CLASSIFICATION_ID=13
JDBC_DRIVER_PATH= C:\dev\ohdm\postgresql-42.1.1.jar
OHDM_CONVERTER_PATH=C:\dev\ohdm\OHDMConverter.jar
TABLENAME=20210307214941
SHP_TO_PGSQL_FILE_PATH = C:\Program Files\PostgreSQL\9.6\bin\shp2pgsql.exe
PGSQL_FILE_PATH = C:\Program Files\PostgreSQL\9.6\bin\psql.exe

2. Step

Here you can import the shapefile data into an Ohdm database. For this it must be ensured that the schema intermediateosm contains the desired table of the shapefile in the ohdm database.


JDBC_DRIVER_PATH= C:\dev\ohdm\postgresql-42.1.1.jar
OHDM_CONVERTER_PATH=C:\dev\ohdm\OHDMConverter.jar
TABLENAME=20210307214941
SHP_TO_PGSQL_FILE_PATH = C:\Program Files\PostgreSQL\9.6\bin\shp2pgsql.exe
PGSQL_FILE_PATH = C:\Program Files\PostgreSQL\9.6\bin\psql.exe

1- The last created table is saved here as the table name TABLENAME. If necessary, you can address a selected table.

2- The path of the JDBC DRIVER have to be set on JDBC_DRIVER_PATH in C:\Program Files\Apache Software Foundation\Tomcat 9.X\bin\configFiles\GenConfigs after the first Step of the import process

3- As with the JDBC DRIVER, the path of the OhdmConverter.jar must be specified as OHDM_CONVERTER_PATH.

4- Then comes the path to the Postgresql database as PGSQL_FILE_PATH.

Very Important !: Some extensions have to be installed in the ohdm database: hstore etc…

The following command must be selected to perform the second step of the import process:


Java -jar Shape2OhdmTool.jar "CONFIG_PATH" TABLENAME

Or you can run the project with an IDE

Entering the table Name is optional, if none is specified, the entered table is considered in GenConfigs. After the import comes “Importing Shape into Ohdm Database : DONE !"

4. Important links:

OHDMConverter/wiki/H2D

OpenHistoricalDataMap account

OHDMImportTool

Shape2OhdmTool

OpenHistoricalMap data sample