=== modified file 'src/docbkx/en/dhis2_implementation_guide_installation_detailed.xml' --- src/docbkx/en/dhis2_implementation_guide_installation_detailed.xml 2011-10-04 14:33:11 +0000 +++ src/docbkx/en/dhis2_implementation_guide_installation_detailed.xml 2011-12-12 07:11:53 +0000 @@ -532,7 +532,30 @@ Now, just restart Apache and you should be able to view https://foo.mydomain.org/dhis. /etc/init.d/apache2 restart -
+
+ Reverse proxy with nginx + Nginx is a high-performance web server and reverse proxy with built with high concurrency, performance and low-memory usage in mind. For more installations, nginx may be a better alternative than the Apache web server for reverse proxy implementations. + To get started, simply install nginx on your system with the following command. + sudo apt-get install nginx + A sample configuration file is below, and should be placed in /etc/nginx/sites-available. + server { + listen *:80; + server_name dhis.foo.org; +location ~ \.(gif|jpg|png|css|js)$ { + +root /var/lib/tomcat6/webapps/; +} + +location / { + proxy_pass http://localhost:8080/; + proxy_set_header X-Real-IP $remote_addr; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + proxy_set_header Host $http_host; + } +} + + You will need to adjust the server_name, and proxy_pass variables to suit your particular setup. The server name must match exactly the name of the server which will be running DHIS. In this particular setup, nginx will serve all static content and then redirect dynamic requests to the application server. Once you have adjusted the configuration file to suit your needs, be sure to activate it by creating a symbolic link in the /etc/nginx/sites-enabled directory which points to the file. +
Performance tuning To increase Tomcat's performance, you can install the native APR library by invoking: === modified file 'src/docbkx/en/dhis2_user_man_creating_gis.xml' --- src/docbkx/en/dhis2_user_man_creating_gis.xml 2011-12-01 07:05:24 +0000 +++ src/docbkx/en/dhis2_user_man_creating_gis.xml 2011-12-12 07:11:53 +0000 @@ -4,26 +4,29 @@ Setting up GIS
Context - - Setting up the GIS simply means storing coordinates for the organisation units you want to show on the map in the database. Coordinates are often distributed in proprietary formats. ESRI shapefiles are the most common geospatial vector data format for desktop applications. You might find shapefiles for your country here or many other geospatial data repositories on the web. Some amount of work needs to be done in order to use these coordinates in DHIS 2 GIS, namely transforming the data into a suitable format and ensuring the name which are contained in the geospatial data match exactly with the names of the organization units which they should be matched to. + Setting up the GIS simply means storing coordinates for the organisation units you want to show on the map in the database. Coordinates are often distributed in proprietary formats and will need to be converted to a format which DHIS2 uses. ESRI shapefiles are the most common geospatial vector data format for desktop applications. You might find shapefiles for your country here or in many other geospatial data repositories on the web. Some amount of work needs to be done in order to use these coordinates in DHIS 2 GIS, namely transforming the data into a suitable format and ensuring the name which are contained in the geospatial data match exactly with the names of the organization units which they should be matched to. If you go to the organisation unit module and edit one of the units, you can see a text field called Coordinates. Here you may fill in its coordinates directly (geojson format) which is useful if you just want to update a couple of units. An example point/facility coordinate: [29.341,-11.154] An example polygon/area coordinates string: [[[[29.343,-11.154],[28.329,-11.342],[28.481,-10.239],[29.833,-10.412]]]] - However, if you are going to e.g. add coordinates for all units at a certain level you don't want to do that manually. This is where the automatic GML import comes into play and the following section explains the preferred way of using it. - The only projection system supported by DHIS2 is EPSG 4326. Coordinates must be stored with the longitude (east/west position) proceeding the latitude (north/south position. If you vector data is in a different format than EPSG 4326, you will need to reproject first before importing. - + However, if you are going to e.g. add coordinates for all units at a certain level you don't want to do that manually. This is where the automatic GML import comes into play and the following section explains the preferred way of using it. + The only co-ordinate reference system supported by DHIS2 is EPSG:4326, also known as geographic longitude/latitude. Coordinates must be stored with the longitude (east/west position) proceeding the latitude (north/south position). If your vector data is in a different CRS than EPSG 4326, you will need to reproject the data first before importing into DHIS2. +
Importing coordinates - Step 1 - Simplify/generalize your shapefile - - The boundaries in shapefiles are usually very accurate. This does not cause any trouble for hardware accelerated desktop based GIS software, but it might be too heavy for the web based GIS application in DHIS 2. Thus, we need to make the boundary lines less detailed by removing some of the line points. Go to http://mapshaper.com/test/demo.html and upload your shapefile. Then, at the center bottom you see a slider that starts at 0%. It is usually ok to drag it up to about 80%. In the left menu you can check "show original lines" to compare the result and you may want to give a different simplification method a try. When you are happy with the result, click "export" in the top right corner. Then check the first of the four options called "Shapefile - polygons", click "create" and wait for the download buttons to appear. Now, download the two files and overwrite the existing .shp and .shx files in your shapefile set (a shapefile is actually a set that has three mandatory files called .shp, .shx and .dbf and sometimes up to 15 files in total). Move on to the next step with your new simplified shapefile. + Step 1 - Simplify/generalize your geographical data + The boundaries in geographical data files are usually very accurate, too much so for the needs of a web-based GIS. This usually does not affect the performance when using GIS files on a a local system, but it is usually necessary to optimize the geographical data for the web-based GIS system of DHIS2. All geographical data needs to be downloaded from the server and rendered in a browser, so if the data is overly complex, the performance of the DHIS2 GIS will be negatively impacted. This optimization process can be described as follows: + + Coordinates: The number of significant decimal digits (e.g. 23.02937874993774) should be shortened to fewer digits (e.g. 23.03). Although this will result in some inaccuracies on the map, given the usual scale at which maps in DHIS2 are produced (> 1:50,000), the loss of precision should not be noticeable. Normally, no more than four significant digits after the decimal point should be necessary. + Polygons: In addition to shortening the number of significant digits, the actual number of points should also be reduced to an optimal level. Finding this optimal level may take a bit of experimentation. Decreasing the precision of the points as well as the number of points through generalization, will lead to degradation of the polygon. However, after a bit of experimentation, an optimal level of generalization can be found, where the accuracy of the polygon is visually acceptable, and the performance of the GIS is optimal. + + For polygons, we need to make the boundary lines less detailed by removing some of the line points. One possible method is the use of MapShaper which is an online tool which can be used to generalize geographical data. To use MapShaper, simply upload your shapefile to the site. Then, at the center bottom you see a slider that starts at 0%. It is usually acceptable to drag it up to about 80%. In the left menu you can check "show original lines" to compare the result and you may want to give a different simplification method a try. When you are happy with the result, click "export" in the top right corner. Then check the first of the four options called "Shapefile - polygons", click "create" and wait for the download buttons to appear. Now, download the two files to your local computer (being sure to rename the file so that you do not overwrite your existing, original data). Move on to the next step with your new simplified shapefile. Step 2 - Convert the shapefile to GML - The recommended tool for geographical format conversions is called "ogr2ogr". This should be available for most Linux distros ("sudo apt-get install gdal-bin"). For Windows, go to http://fwtools.maptools.org/ and download "FWTools", install it and open up the FWTools command shell. During the format conversion we also want to ensure that the output has the correct coordinate projection (called EPSG:4326 with geographic longitude and latitude). For a more detailed reference of geographic coordinates, please refer to this site. If you have already reprojected the geographic data to the geographic latitude/longitude (EPSG:4326) system, there is no need to explicitly define the output coordinate system, assuming that ogr2ogr can determine the input spatial reference system. You can determine the spatial reference system by executing the following command. + The recommended tool for geographical format conversions is called "ogr2ogr". This should be available for most Linux distributions ("sudo apt-get install gdal-bin"). For Windows, go to http://fwtools.maptools.org/ and download "FWTools", install it and open up the FWTools command shell. During the format conversion we also want to ensure that the output has the correct coordinate projection (called EPSG:4326 with geographic longitude and latitude). For a more detailed reference of geographic coordinates, please refer to this site. If you have already reprojected the geographic data to the geographic latitude/longitude (EPSG:4326) system, there is no need to explicitly define the output coordinate system, assuming that ogr2ogr can determine the input spatial reference system. You can determine the spatial reference system by executing the following command. ogrinfo -al -so filename.shp Assuming that the projection is reported to be EPSG:27700 by ogrinfo, we can transform it to EPSG:4326 by executing the following command. ogr2ogr -s_srs EPSG:27700 -t_srs EPSG:4326 -f GML filename.gml filename.shp If the geographic data is already in EPSG:4326, you can simply transform the shapefile to GML by executing the following command. @@ -41,11 +44,11 @@ Go to Services -> Import-Export, select "Preview", select the GML file and click "Import". Look for new/updated organisation units. Our intention is to add coordinates to already existing organisation units in the database, so we want as many updates as possible and 0 new. Those listed as new will be created as root units and mess up the organisation unit trees in DHIS 2. If any listed as new, click the number and the organisation units in question will appear in the list below. If there are any slight misspellings compared to the organisation unit names in the database - fix them and do the preview again. Otherwise, click the "discard all" button below the list and then the "Import all" button above the list. - If the import process completes successfully, you are good to go. If not, check the log for hints and look for common errors such as: + If the import process completes successfully, you should now be able to utilize the geographical data in the DHIS2 GIS. If not, check the log for hints and look for common errors such as: - Name duplicates in the GML file. The name column in the database is unique and does not accept two organisation units with the same name. - The "shortname" column in the organisationunit table in your database has a too small varchar definition. Increase it to 100. - - Special name characters in the GML file. Rename or remove. + - Special name characters in the GML file. Be sure to convert these to appropirate XML equivalents or escape sequences.
Administering the GIS module